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.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Pivot Table Data

Author  Topic 

eljapo4
Posting Yak Master

100 Posts

Posted - 2012-08-31 : 10:46:57
Hi I've the following sample of data

ID ModelNumber FanSpeed MeanWaterTemp Performance
1 SRX080M 1 30 163
1 SRX080M 1 33 204
1 SRX080M 1 35 245
1 SRX080M 1 38 286
1 SRX080M 1 40 327
1 SRX080M 1 43 368
1 SRX080M 1 45 409
1 SRX080M 2 30 314
1 SRX080M 2 33 394
1 SRX080M 2 35 474
1 SRX080M 2 38 554
1 SRX080M 2 40 634
1 SRX080M 2 43 714
1 SRX080M 2 45 794
1 SRX080M 3 30 485
1 SRX080M 3 33 613
1 SRX080M 3 35 741
1 SRX080M 3 38 869
1 SRX080M 3 40 996
1 SRX080M 3 43 1124
1 SRX080M 3 45 1252

Is it possible for me to pivot this data with SQL query so it looks like
ID (X-Axis)
FanSpeed (Y-Axis) MeanTemp (Sub-(Y-Axis)) Performance (Z-Axis)


visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-08-31 : 11:18:45
this looks more of report format rather than pivoting. this format can be very easily achieved using reporting tools like SSRS using nested containers

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

eljapo4
Posting Yak Master

100 Posts

Posted - 2012-09-03 : 03:51:17
I need to diplay this data in an asp.net application and was thinking that it may be easier to manipulate the SQL results into a pivot format rather than the gridview within the application itself
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-09-03 : 15:25:50
the format cant be obtained using sql query unless you apply some ugly conditional logic

the way you should be doing this is using flattened sql query and doing the required formatting after populating recordset in .net

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

eljapo4
Posting Yak Master

100 Posts

Posted - 2012-09-04 : 03:47:19
Thanks for your advice!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-09-05 : 21:50:29
np

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -