Click here to Skip to main content
15,885,179 members
Please Sign up or sign in to vote.
3.33/5 (2 votes)
See more:
sir, i have a query that result is like:-

StudentID -- Course -- Percentage
101 -- Highscl -- 70
101 -- Inter -- 77


i need to show this result is like:-

StudentID -- Course1 -- Percentage1 -- Course2 --- Percentage2
101 -- Highscl -- 70 -- Inter -- 77


how can i do it.
Posted

In SQL Server you can use the PIVOT function to transform the data from rows to columns.
Check these examples
Efficiently convert rows to columns in sql server
Using PIVOT and UNPIVOT
Simple Way To Use Pivot In SQL Query
 
Share this answer
 
Comments
CPallini 5-Sep-14 4:13am    
5.
thatraja 5-Sep-14 4:20am    
My 5! too
Dilan Shaminda 5-Sep-14 4:29am    
Thank you sir :-)
Agree with Solution 1. PIVOT is bese option. Here alternative ways to achieve that without using PIVOT.
Pivoting data in SQL Server[^]
 
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