MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Need a SQL Query to join the result of two queries

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
priyam
Beginner


Joined: 05 Jul 2006
Posts: 16
Topics: 12

PostPosted: Tue Nov 21, 2006 5:50 am    Post subject: Need a SQL Query to join the result of two queries Reply with quote

Need a SQL Query:

I have three input tables. CUST_DETAILS,EUITY_DETAIL and BOND_DETAIL.

Input:
CUST_DETAILS:

ACCT NAME
511 PRIYA
512 MANOJI

EQUITY_DETAIL

ID ACCT DATE CIP

610 511 11/03/2006 IBM
610 511 11/04/2006 MFST
611 512 11/03/2006 BBY
611 512 11/04/2006 CSCO

BOND_DETAIL

ID ACCT DATE CIP
610 511 11/03/2006 CDDE1
610 511 11/04/2006 CDDE2
611 512 11/03/2006 CDDE3
611 512 11/04/2006 CDDE4

My Output Should be:

ACCT DATE CIP
511 11/03/2006 IBM
511 11/04/2006 MFST
511 11/03/2006 CDDE1
511 11/04/2006 CDDE2

512 11/03/2006 BBY
512 11/04/2006 CSCO
512 11/03/2006 CDDE3
512 11/04/2006 CDDE4

When i use Union i got the output like

ACCT DATE CIP
511 11/03/2006 IBM
511 11/03/2006 CDDE1
511 11/04/2006 MFST
511 11/04/2006 CDDE2

512 11/03/2006 BBY
512 11/03/2006 CDDE3
512 11/04/2006 CSCO
512 11/04/2006 CDDE4

It displays first with the date 11/03/2006 for the ACCT 511 from both the tables and then for 11/04/2006.

Can anyone help me on this?








[/b]
Back to top
View user's profile Send private message
bauer
Intermediate


Joined: 10 Oct 2003
Posts: 317
Topics: 50
Location: Germany

PostPosted: Tue Nov 21, 2006 6:27 am    Post subject: Reply with quote

priyam,

Question 1:

are you talking about a sort on column acct , date and for rows with equal acct ,date first the rows from table EQUITY_DETAIL and second rows from table BOND_DETAIL should be in the result set? Is this correct?


Question 2:
are any fields required from table CUST_DETAILS ?


regards,
bauer
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group