qube09
asked on
sql 2005 pivot data
id date time
id1 11/8/2013 900
id1 11/8/2013 1000
id2 11/8/2013 910
id2 11/8/2013 1010
if I have data like the above and I want to rearrange it like this:
id date time1 time2
id1 11/8/2013 900 1000
id2 11/8/2013 910 1010
What is the best sql to do that? Acceptable answer must be for sql server 2005 and sql only.
id1 11/8/2013 900
id1 11/8/2013 1000
id2 11/8/2013 910
id2 11/8/2013 1010
if I have data like the above and I want to rearrange it like this:
id date time1 time2
id1 11/8/2013 900 1000
id2 11/8/2013 910 1010
What is the best sql to do that? Acceptable answer must be for sql server 2005 and sql only.
Are there only ever two times per ID/date, or can there be just one or >2?
ASKER
generally but could be four
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
HINT: Look at using MIN, MAX, and GROUP BY for your query.