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

Select specific based on multiple columns


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

Active User


Joined: 03 Feb 2007
Posts: 175
Location: PUNE(INDIA)

PostPosted: Fri Jan 11, 2008 6:45 pm
Reply with quote

Hi ALL,
I have a DB2 table having few columns (Say Col1, Col2, Col3, Col4,......).
None of them is Primary key and all have duplicates allowed.
Table have several thousand rows.
Now I want to select only those rows having following combination values for first 3 columns.
Code:

Col1            Col2         Col3
A                B             C
A                Z             M
Q                F             L
.                 .             .
.                 .             .
.                 .             .

This data have say 50 rows.

Duplicates are allowed in my result set.
This has to be done thru SQL query which I will run thru SPUFI. ( and not thru COBOL program)
--Parag
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


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

PostPosted: Fri Jan 11, 2008 7:01 pm
Reply with quote

ParagChouguley wrote:
Hi ALL,
I have a DB2 table having few columns (Say Col1, Col2, Col3, Col4,......).
None of them is Primary key and all have duplicates allowed.
Table have several thousand rows.
Now I want to select only those rows having following combination values for first 3 columns.
Code:

Col1            Col2         Col3
A                B             C
A                Z             M
Q                F             L
.                 .             .
.                 .             .
.                 .             .

This data have say 50 rows.

Duplicates are allowed in my result set.
This has to be done thru SQL query which I will run thru SPUFI. ( and not thru COBOL program)
--Parag


How about showing us what you have tried and the results!
Back to top
View user's profile Send private message
ParagChouguley

Active User


Joined: 03 Feb 2007
Posts: 175
Location: PUNE(INDIA)

PostPosted: Fri Jan 11, 2008 8:18 pm
Reply with quote

I couldn't do this !

--Parag
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


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

PostPosted: Fri Jan 11, 2008 8:52 pm
Reply with quote

ParagChouguley wrote:
I couldn't do this !

--Parag

Code:

SELECT * FROM TABLE
WHERE (COL1 = 'A' AND COL2 = 'B' AND COL3 = 'C')
   OR (COL1 = 'A' AND COL2 = 'Z' AND COL3 = 'M')
   OR (COL1 = 'Q' AND COL2 = 'F' AND COL3 = 'L');


That is difficult.
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 INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Remote Unload of CLOB Columns DB2 6
No new posts Multiple table unload using INZUTILB DB2 2
No new posts Grouping by multiple headers DFSORT/ICETOOL 7
Search our Forums:

Back to Top