Reputation: 893
I have a table like this
ID | A | B | InTime | OutTime
10 | 19 | 18078 | 2011-09-07 16:51:56.807 | 2011-11-09 22:39:02.487
But I want to get data in below format
ID | A | B | Time
10 | 19| 18078 | 2011-09-07 16:51:56.807
10 | 19| 18078 | 2011-11-09 22:39:02.487
Sorry in advance as I am a bit naive in such complex queries. I tried to search in, found various options like PIVOT, UNPIVOT, CROSS APPLY, but wan unable to found any exact solution/direction to look out in.
Thanks a lot in advance
Upvotes: 1
Views: 64
Reputation: 1
I believe this should get you what you want:
select id,a,b,InTime as 'Time'
from table
union all
select id,a,b,OutTime
from table
Upvotes: 0
Reputation: 6477
select id,a,b,timein as Time from table
union all
select id,a,b,outtime from table
order by id,a,b,time
Upvotes: 0
Reputation: 35780
Try this:
Select ID, A, B, InTime From Table
Union All
Select ID, A, B, OutTime From Table
Upvotes: 3
Reputation: 40393
I'd probably go with something simple, like a union all
:
select ID, A, B, InTime [Time] from myTable
union all
select ID, A, B, OutTime [Time] from myTable
Upvotes: 2