Click here to Skip to main content
Rate this: bad
good
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 at 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 at 3-Dec-12 8:18am
   
No one help me i want display multiple row as column not a single row as column
@AmitGajjar at 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 at 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 at 3-Dec-12 8:22am
   
Ok let me try
@AmitGajjar at 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
0 Maciej Los 225
1 OriginalGriff 145
2 manoj kumar choubey 115
3 _Amy 115
4 Sergey Alexandrovich Kryukov 105
0 OriginalGriff 7,320
1 Sergey Alexandrovich Kryukov 6,043
2 Maciej Los 3,749
3 Peter Leow 3,408
4 DamithSL 2,555


Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 3 Dec 2012
Copyright © CodeProject, 1999-2014
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