Click here to Skip to main content
15,904,503 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In table records as follows

Facid Q1 Q2 Q3 Batchid
1 2 3 4 B001
2 4 4 5 B001
1 5 1 2 B002
2 4 5 3 B002
1 4 1 2 B003
2 5 4 3 B003

Using above records i want output as follows using sql query

B001 B002 B003
Facid Q1 Q2 Q3 Q1 Q2 Q3 Q1 Q2 Q3

1 2 3 4 5 1 2 4 1 2
2 4 4 5 4 5 3 5 4 3

for getting a above output how can i write a sql query.
kindly please help me.using pivot how can i do using sql query.

Regards
Narasiman
Posted

1 solution

Try this

Simple Way To Use Pivot In SQL Query[^]
SQL - Pivot with Grand Total Column and Row[^]

Still am not sure if it is possible to bring double header as you had requested.


Hope this helps

Regards,
Dinesh Kumar.V.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900