Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search Memberlist Usergroups Profile Log in to check your private messages Log in
 
CASE statement in WHERE clause

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
Author Message
sri.mainframes

New User


Joined: 16 Feb 2006
Posts: 29
Location: MUMBAI

PostPosted: Fri Apr 07, 2006 7:27 pm    Post subject: CASE statement in WHERE clause
Reply with quote

hi ,

Can we code a CASE statement in a WHERE clause in a QUERY?
Back to top
View user's profile Send private message
References
priyesh.agrawal

Global Moderator


Joined: 28 Mar 2005
Posts: 1509
Location: Chicago, IL

PostPosted: Fri Apr 07, 2006 8:06 pm    Post subject: Re: CASE statement in WHERE clause
Reply with quote

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
View user's profile Send private message
sri.mainframes

New User


Joined: 16 Feb 2006
Posts: 29
Location: MUMBAI

PostPosted: Fri Apr 07, 2006 8:13 pm    Post subject:
Reply with quote

thanks priyush
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1