IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Please help in designing the query


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Soundararajan

New User


Joined: 07 Jan 2007
Posts: 13
Location: INDIA

PostPosted: Mon Nov 12, 2007 4:31 pm
Reply with quote

Hi,

I have a table structure as below:

C_CODE, P_61, P_62, P_63

I want to fetch C_CODE column value.

For example, If input value contains 61 then I have to use P_61 column and I have to fetch appropriate C_CODE column value. If input value contains 62 then I have to use P_62 column and I have to fetch appropriate C_CODE column value and so on. Please help me to write the above mentioned scenario in a single query.

Thanks in advance.
Back to top
View user's profile Send private message
Srihari Gonugunta

Active User


Joined: 14 Sep 2007
Posts: 295
Location: Singapore

PostPosted: Mon Nov 12, 2007 8:18 pm
Reply with quote

What do the columns P_61, P_62, P_63 contain?
Just wanted to know how you want the query when your input is 61.
Back to top
View user's profile Send private message
Soundararajan

New User


Joined: 07 Jan 2007
Posts: 13
Location: INDIA

PostPosted: Mon Nov 12, 2007 9:39 pm
Reply with quote

P_61, P_62, P_63 contains X.

Thanks,
Soundar.
Back to top
View user's profile Send private message
Soundararajan

New User


Joined: 07 Jan 2007
Posts: 13
Location: INDIA

PostPosted: Mon Nov 12, 2007 9:56 pm
Reply with quote

If my input is 61, I have to check whether P_61 contains X or not, If my input is 62 I have to check whether P_62 contains X or not and so on..and I have to retrieve C_CODE value also.

Thanks,
Soundar.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Mon Nov 12, 2007 11:28 pm
Reply with quote

Try this

Code:
when (:input = '61' and p_61 = 'X')
    or (:input = '62' and p_62 = 'X')
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts RC query -Time column CA Products 3
No new posts Dynamically pass table name to a sele... DB2 2
No new posts Query on edit primary command CLIST & REXX 5
No new posts Query on edit primary command CLIST & REXX 1
No new posts Issue with EXEC CICS QUERY SECURITY c... CICS 6
Search our Forums:

Back to Top