View previous topic :: View next topic
|
Author |
Message |
sri.mainframes
New User
Joined: 16 Feb 2006 Posts: 29 Location: MUMBAI
|
|
|
|
hi ,
Can we code a CASE statement in a WHERE clause in a QUERY? |
|
Back to top |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
Quote: |
Can we code a CASE statement in a WHERE clause in a QUERY? |
Why not... check below query...It is taken from the manuals...
Quote: |
| Example 2 (searched-when-clause): You can also use a CASE expression to
| avoid "division by zero" errors. From the EMPLOYEE table, find all
| employees who earn more than 25 percent of their income from commission,
| but who are not fully paid on commission:
| SELECT EMPNO, WORKDEPT, SALARY+COMM FROM EMPLOYEE
| WHERE (CASE WHEN SALARY=0 THEN 0
| ELSE COMM/(SALARY+COMM)
| END) > 0.25; |
Regards,
Priyesh. |
|
Back to top |
|
|
sri.mainframes
New User
Joined: 16 Feb 2006 Posts: 29 Location: MUMBAI
|
|
|
|
thanks priyush |
|
Back to top |
|
|
|