Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
run
Starting Member
7 Posts |
Posted - 2008-02-11 : 11:07:42
|
| Probably simpleI have a table with 4 rows: Name, Event, EventDuration & TripA person can have several Events during a single trip, so you can have the following:name1 | Event1 | EventDuration | Trip1name1 | Event2 | EventDuration | Trip1name1 | Event3 | EventDuration | Trip1name2 | Event1 | EventDuration | Trip2name2 | Event3 | EventDuration | Trip2name3 | Event2 | EventDuration | Trip2I there a smart way to construct an sql statement so I get the following representation:Name | Trip | Duration Event1 | Duration Event2 | Duration Event3 name1 | Trip1 | EventDuration | EventDuration | EventDuration name2 | Trip2 | EventDuration | null | EventDuration name3 | Trip2 | null | EventDuration | nullThere are 6 different event types to keep track ofRight now I make 6 different views and join all six, but is there a smart way to just do a single sql statement? |
|
|
jdaman
Constraint Violating Yak Guru
354 Posts |
Posted - 2008-02-11 : 11:10:22
|
| Look up PIVOT operator in BOL. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-02-11 : 11:15:19
|
| You might need to apply PIVOT operator along with dynamic sql if all trips dont contain same number of events. |
 |
|
|
run
Starting Member
7 Posts |
Posted - 2008-02-11 : 11:41:23
|
| Thanks! |
 |
|
|
|
|
|