question

Mr.X avatar image
Mr.X asked

Help!!! how to transpose below table in T-sql

I need T-sql query to transpose below table. ![as per this][1] [1]: /storage/temp/3908-example.png Please let me know if further details are required.
sql-server-2008t-sqltables
example.png (12.2 KiB)
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

sjimmo avatar image sjimmo commented ·
What have you tried? Give us the code you used.
0 Likes 0 ·

1 Answer

·
Oleg avatar image
Oleg answered
There is no need to change T-SQL script. All you need to do is this: 1. Click inside of the results (pivot table) so that the pivot table list is visible. If it is still not visible then right-click and pick "**Show Field List**" from the popup menu. 2. Drag the fields from the "**Row Labels**" area to the "**Column Labels**" 3. All the fields which you currently have in the **Values** are are also present in the "**Column Labels**", they are now denoted as **Σ Values**. So, drag the **Σ Values** from the **Column Labels** to the **Row Labels** The above procedure will transpose rows to columns and vice versa. Hope this helps. Oleg
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.