Link to home
Start Free TrialLog in
Avatar of qube09
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.
Avatar of Brendt Hess
Brendt Hess
Flag of United States of America image

There are a lot of assumptions that need to be made to answer this question. And this sort of looks like instructional work, not real world work.  This would not need to be pivot data at all, and as structured really is not suited to be pivot data.  

HINT: Look at using MIN, MAX, and GROUP BY for your query.
Are there only ever two times per ID/date, or can there be just one or >2?
Avatar of qube09
qube09

ASKER

generally but could be four
ASKER CERTIFIED SOLUTION
Avatar of Sharath S
Sharath S
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial