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 |
|
michaelgr
Starting Member
9 Posts |
Posted - 2009-10-26 : 03:10:13
|
| Hello,I have a database with date column (equipmenttime). I want to sort the results by dates but the sorting will be to columns (in the result).The query has to calculate something by month (the sorting to months will be to columns in the results).for example :select *from databasegroup by month(equipmenttime)but this grouping groups the results to rows in the results but i need it to be to columns.I thought to do it by case when month(equipmenttime)="july" then......but it need to do it to all the months and i have 2 columns per month. Is there any easier way? |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-10-26 : 03:16:04
|
check out PIVOT operator in Books OnLine KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|