Joined: 28 Mar 2005 Posts: 1509 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;