Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Need help in writing one Query.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
batu544

New User


Joined: 21 Jul 2005
Posts: 16
Location: bangalore

PostPosted: Mon Mar 30, 2009 3:02 am    Post subject: Need help in writing one Query.
Reply with quote

Hi All,
I have a requirement with following 2 tables. Here is the tables.

TAB1.

Code:

WHSE                  CLASS      SUBCL      PNUM             PURGE_YN
---------             --------   --------   -----------      ------
0755                    01          1         11111             P
0755                    02          2         22222             
0755                    03          3         33333             P
0800                    01          1         11111             P
0800                    03          3         33333             P
0800                    04          4         44444             P
0855                    01          1         11111             P
0855                    04          4         44444             P
0900                    04          4         44444             


TAB2
-------

Code:

WHSE1                 CLASS1     SUBCL1     PNUM1            TEMP_YN
---------             --------   --------   -----------      ------
0755                    01          1         11111             P
0755                    02          2         22222             
0755                    03          3         33333             P
0800                    01          1         11111             P
0800                    03          3         33333             T
0800                    04          4         44444             I
0855                    01          1         11111             I
0855                    04          4         44444             P
0900                    04          4         44444             P



Now, need one query which will select only select the MMS # ( combination of class, subcl and PNUM field or combination of class1, subcl1 and PNUM1 field) where ....

1. PURGE_YN = 'P' and the corresponding TEMP_YN = 'I" and there should not be a PURGE_YN = ' ' for the same MMS # in any other row.


2. If for all the MMS # the PURGE_YN = 'P" and TEMP_YN = 'P' then exlude MMS number.

3. exclude those MMS # where both PURGE_YN = ' ' and TEMP_YN = ' '.



Thanks in advance

batu
Back to top
View user's profile Send private message

dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon Mar 30, 2009 3:33 am    Post subject:
Reply with quote

Hello,

It appears that the sample data does not contain examples of all of the rules (or i've misunderstood something icon_confused.gif ). . .

Please review the sample input from the 2 tables and add/change anything as you determine necessary. Please practice with Preview before clicking Submit - Preview lets you see your post as it will appear to the forum rather than how it appears in the Reply editor.

Once you have verified the input is as you want, please post the expected output that would be selected by this query from the sample input posted.
Back to top
View user's profile Send private message
batu544

New User


Joined: 21 Jul 2005
Posts: 16
Location: bangalore

PostPosted: Mon Mar 30, 2009 4:09 pm    Post subject:
Reply with quote

Hi,
yes, the sample data contains all the example of all the conditions..


the result table will be ..

Code:


WHSE1                      CLASS1       SUBCL1      PNUM1   
---------                ----------     ----------    ----------
0855                              01          1         11111

Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10211
Location: italy

PostPosted: Mon Mar 30, 2009 4:16 pm    Post subject: Reply to: Need help in writing one Query.
Reply with quote

what happened to ??
Code:
0800                    04          4         44444
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Join in SQL Query vickey_dw DB2 2 Tue Jan 17, 2017 12:15 am
This topic is locked: you cannot edit posts or make replies. MQ setup query mohitsaini Java & MQSeries 4 Sun Jan 08, 2017 1:53 am
No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us