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
 

 

Join in SQL Query

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

New User


Joined: 10 Jun 2015
Posts: 42
Location: India

PostPosted: Tue Jan 17, 2017 12:15 am    Post subject: Join in SQL Query
Reply with quote

Hi All,

Table1 contains details of employee which i want to fetch based on comman key Sap id in table2.

I have written below query to fetch the details of a employee and its reporting maneger(RM)

Code:
Select
  A.Name
 ,A.Lastname
 ,A.Empid
 ,A.Telephone'
 ,B.Designation
 ,A.RM
 ,D.Name
 ,D.Lastname
 ,D.Empid
 ,D.Telephone
 ,D.RM
from Table1 A
    ,Table2 B
Left Join Table1 D
    on D.Empid = A.RM
Where
     A.Empid = '219057'
And  B.Sapid = A.Sapid


But i am facing problem to fetch designation of RM(Reporting manager) in above query as its present in table2. Please help me with this.
Back to top
View user's profile Send private message

RahulG31

Active User


Joined: 20 Dec 2014
Posts: 378
Location: USA

PostPosted: Tue Jan 17, 2017 11:37 am    Post subject: Reply to: Join in SQL Query
Reply with quote

Provide Sample data and expected output. Describe your requirement clearly and also what is the exact problem you are facing.
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 1736
Location: NY,USA

PostPosted: Tue Jan 17, 2017 11:20 pm    Post subject:
Reply with quote

You already getting what you want unless you stated incorrectly.
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 Reduce CPU Times for Join Sort santoshn SYNCSORT 12 Sat Jun 10, 2017 1:40 pm
No new posts Need DB2 query to fetch previous row ! Chandan1993 DB2 10 Sat Jun 03, 2017 10:43 am
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 Join giving more records than expected Danielle.Filteau SYNCSORT 2 Thu Mar 09, 2017 3:28 am
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm


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