satishboddu
New User
Joined: 02 Aug 2011 Posts: 17 Location: India
|
|
|
|
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 .. |
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
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>
; |
|
|