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 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 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