Click here to Skip to main content
15,886,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello Friends ,

i have record like in my table


SchoolCode
Grade Type
Girls
Boys
ABC
1
5
12
ABC
2
7
14
ABC
3
12
5
ABC
4
14
3
ABC 5
22 1
ABC
6
15
2
ABC
7
18
7
ABC
8
19
9


And i want to get result like

SchoolCode Grade1Girls Grade1Boys Grade2Girls Grade2Boys...up to Grade8Girls Grade8Boys

So what can i do???

please help me
Posted

Shingala,

You need to check the pivoting/unpivoting in SQL server. Please check this http://blog.sqlauthority.com/2008/06/07/sql-server-pivot-and-unpivot-table-examples/[^]

Regards
Pawan
 
Share this answer
 
Comments
Shingala Anil 3-Dec-12 8:18am    
No one help me i want display multiple row as column not a single row as column
 
Share this answer
 
Comments
Shingala Anil 3-Dec-12 8:18am    
No one help me i want display multiple row as column not a single row as column
AmitGajjar 3-Dec-12 8:20am    
If PIVOT not work for you, then you can create one CURSOR and iterate through rows and generate temporary table and fill the data.
Shingala Anil 3-Dec-12 8:19am    
i want to display Gradetype With Girls and Boys I Need 16 Column as Output 8 for Girls and 8 For Boys Bcoz Gradetype have 8 Values
Shingala Anil 3-Dec-12 8:22am    
Ok let me try
AmitGajjar 3-Dec-12 8:23am    
Although CURSOR logic will look complicated but it will work in your case.

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