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
 
Returning multiple rows for one row in the table

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

New User


Joined: 02 Aug 2011
Posts: 17
Location: India

PostPosted: Thu May 09, 2013 3:14 pm    Post subject: Returning multiple rows for one row in the table
Reply with quote

Hi ,

I have an Employee table which has employee records, I need to write a query which fetches employee records from the table based on certain criteria and also for each employee i need more than one output records in the result set of the query.

Example :

Code:
EMP_NO   EMP_Name   DOJ                 
101           Satish          01-05-2009
102           Srinu            04-20-2010

Output
Code:
EMP_NO   EMP_NAME       DOJ             WORK_SHIFT
101           Satish          01-05-2009          D
101           Satish          01-05-2009          N
102           Srinu            04-20-2010          D
102           Srinu            04-20-2010          N

How do we achieve this in SQL ?

Thanks in Advance

Satish ..
Back to top
View user's profile Send private message

Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1542
Location: Andromeda Galaxy

PostPosted: Thu May 09, 2013 3:26 pm    Post subject:
Reply with quote

Tr this

Code:
SELECT EMP_NO ,EMP_Name, DOJ,'D'
FROM <TABLENAME>
WHERE <CONDITION>
UNION ALL
SELECT EMP_NO ,EMP_Name, DOJ,'N'
FROM <TABLENAME>
WHERE <CONDITION>
;
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 Update table without cursor Ron Klop DB2 3 Wed Oct 11, 2017 1:06 pm
No new posts Table(Unicode(Graphic) table) loading... muralikrishnan_new DB2 0 Thu Oct 05, 2017 5:10 pm
No new posts Conditional highlighting of rows in I... packerm CLIST & REXX 2 Thu Sep 21, 2017 6:50 pm
No new posts ejck thru rexx to multiple jobs insid... Susanta All Other Mainframe Topics 5 Tue Sep 19, 2017 1:39 pm
No new posts Insert a Row_number into table useit DB2 2 Tue Sep 19, 2017 1:07 pm

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