question

Arihant avatar image
Arihant asked

Convert rows into column column into rows

All I need is convert Column(A1/A2) into rows and rows(1 into Jan) into columns. Input: Here A1/A2 belongs to say A and they are calculated as A1/A2 for each month. Month A1 A2 B1 B2 C1 C2 1 120 60 40 80 120 120 2 50 50 40 20 60 30 3 50 25 40 10 90 30 I need below o/p without using pivot and unpivot O/P: X Jan(1 is denoting Jan) Feb Mar A 120/60(calculation:A1/A2) 40/80 120/120 B 50/50 40/20 60/30 C 50/25 40/10 90/30 I tried but my query is too long as I am using case and Union All three times each For A1 A2,B1 B2,C1 C2 etc. Can you pls help me out. Thanks in advance
sqltsqlsqlserver
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.

Can you show us the code you have tried? Can you please post a create table statement with some sample data then shoe an example of the what the data would look like when correctly put into rows and columns etc should help us understand exactly what you need.
0 Likes 0 ·

0 Answers

·

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.