Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Need a SQL query to do the following in two tables

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

New User


Joined: 29 May 2006
Posts: 0

PostPosted: Thu Aug 24, 2006 10:22 am    Post subject: Need a SQL query to do the following in two tables
Reply with quote

I need a query to do the following in two tables say AAA and BBB

AAA has columns a,b,c,d,e,f,g,h

BBB has columns h,i,j,k

I have to fetch rows such that a,b,c,d,e,f,g should be equal
h should be different
i,j,k -any one of the values shopuld differ



example

a b c d e f g h i j k

1 2 3 4 5 6 7 8 9 10 11
1 2 3 4 5 6 7 17 9 10 14

or

a b c d e f g h i j k

1 2 3 4 5 6 7 8 9 10 11
1 2 3 4 5 6 7 17 9 14 11

or

a b c d e f g h i j k

1 2 3 4 5 6 7 8 9 10 11
1 2 3 4 5 6 7 17 14 10 11



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

red_roses

New User


Joined: 31 Oct 2005
Posts: 27

PostPosted: Thu Aug 24, 2006 10:07 pm    Post subject:
Reply with quote

you say a,b,c,d,e,f,g should be equal ... equal to what.. as per your description BBB has none of the rows from a to g. so on what are you going to match..????
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


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

PostPosted: Sat Sep 02, 2006 9:53 am    Post subject: Re: Need a SQL query to do the following in two tables
Reply with quote

I hope, I understood what you wanted to convey... else excuse me for wasting your time...

Code:
SELECT * FROM
   (SELECT * FROM
      (SELECT * FROM AAA, BBB WHERE AAA.H = BBB.H)
   GROUP BY A,B,C,D,E,F,G HAVING COUNT(*) >1)
GROUP BY I,J HAVING COUNT(*) >1
UNION
SELECT * FROM
   (SELECT * FROM
      (SELECT * FROM AAA, BBB WHERE AAA.H = BBB.H)
   GROUP BY A,B,C,D,E,F,G HAVING COUNT(*) >1)
GROUP BY J,K HAVING COUNT(*) >1
UNION
SELECT * FROM
   (SELECT * FROM
      (SELECT * FROM AAA, BBB WHERE AAA.H = BBB.H)
   GROUP BY A,B,C,D,E,F,G HAVING COUNT(*) >1)
GROUP BY I,K HAVING COUNT(*) >1
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 query to fetch record which has only ... maxsubrat DB2 12 Mon Dec 11, 2017 5:03 pm
No new posts How to query MAXGENS of an existing P... Chuchulo Hatyzak JCL & VSAM 4 Wed Nov 22, 2017 10:23 pm
No new posts Native SQL Query kishpra DB2 1 Wed Nov 22, 2017 8:38 pm
No new posts Query on IEFBR14 with GDG Ashishpanpaliya JCL & VSAM 4 Tue Nov 07, 2017 8:34 pm
No new posts Selecting a row from multiple tables! Vignesh Sid DB2 2 Thu Oct 26, 2017 6:09 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us