Click here to Skip to main content
14,735,180 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SIR, i have a table in which 3 columns studentid,qualification and board.
it show like....


Studentid - qualification - board
1 - highschool - cbse
1 - intermidiate - cbse
2 - highschool - up board
2 - intermidiate - up board


i need a query that give result like...

studentid - qualification-1 - qualification-2 - board-1 - board-2
1 - highschool - intermidiate - cbse - cbse
2 - highschool - intermidiate - up board - up board




can any one solve it..
Posted
Updated 9-Jul-14 21:56pm
v2
Comments
CHill60 9-Jul-14 9:27am
   
Look up "SQL Pivot" ... e.g. this article Simple Way To Use Pivot In SQL Query[^]
Gauri Chodanker 9-Jul-14 10:22am
   
Please provide us with a tabular format of data which looks good to you and can be easily understood

1 solution

You just need to give each row a unique id. Then you can do this:

select t1.studentid,
	t1.Qualification as qualification1, 
	t2.qualification as qualification2,
	t1.board as board1,
	t2.Board as board2
from TestSQB t1 inner join
	TestSQB t2 on t1.studentid = t2.studentid
		and t1.uniqueid < t2.uniqueid
   

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