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 Create procedure issues -628 when add... chandraBE DB2 1 Mon Sep 18, 2017 12:16 pm
No new posts Can we limit length in concatenation ... balaji81_k DB2 7 Tue Aug 22, 2017 2:50 am
No new posts Identify top 30 big tables or indexes... ashek15 DB2 0 Fri Jun 16, 2017 10:01 am
No new posts Need DB2 query to fetch previous row ! Chandan1993 DB2 10 Sat Jun 03, 2017 10:43 am
No new posts Data replication from multiple Db2 ta... kishpra DB2 9 Mon Mar 27, 2017 9:58 pm

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