Click here to Skip to main content
12,502,578 members (56,603 online)
Rate this:
 
Please Sign up or sign in to vote.
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 3-Dec-12 1:30am
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  
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
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

  Permalink  
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160919.1 | Last Updated 3 Dec 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100