SQL Server: How I create a horizontal table -


for example if have next table:

| sensorid |date| value | ------------------------- |    65000 | 00 |    32 | |    65000 | 01 |    40 | |    65000 | 02 |    35 | |    65000 | 03 |    37 | |    65000 | 04 |    39 | |    65001 | 00 |    06 | |    65001 | 01 |    10 | |    65001 | 02 |    15 | |    65001 | 03 |    26 | |    65001 | 04 |    39 | 

i want convert table?

| sensorid | 00 | 01 | 02 | 03 | 04 | ------------------------------------ | 65000    | 32 | 40 | 35 | 37 | 39 | | 65001    | 6  | 10 | 15 | 26 | 39 |  

is there special method or have find way iterate while?

i need help. thank you!

pivot need:

select sensorid,         [00], [01], [02], [03], [04] mytable pivot (   max(value)   date in ([00], [01], [02], [03], [04]) ) pivottable; 

http://msdn.microsoft.com/en-us/library/ms177410(v=sql.105).aspx


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -