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: 10231
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 JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts Writing on to GSAM variable length rohanthengal JCL & VSAM 6 Fri Mar 03, 2017 7:46 pm
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Omegamon for DB2 query ashek15 DB2 0 Wed Feb 15, 2017 11:25 am
No new posts Query on DB2 WLM stored procedures ashek15 DB2 8 Sun Feb 12, 2017 11:13 pm


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