Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase

Row to Column (Pivot) Expand / Collapse
Posted Friday, March 22, 2013 4:28 AM


Group: General Forum Members
Last Login: Tuesday, December 23, 2014 9:49 PM
Points: 429, Visits: 93
SELECT S.UniversityNo
FROM SStudentUnivPerformamce U
INNER JOIN SStudent S oN U.SStudentID = S.StudentID
INNER JOIN SSubject SU ON U.SSubjectID = SU.SSubjectID
WHERE U.SBatchID = 4
GROUP BY S.UniversityNo
ORDER BY S.UniversityNo,U.SSubjectID

I want the Output Like This
UniversityNo Name Sub1 Sub2 Sub3 ......
123 Raja P F P ....
124 Kumar P F P ....
125 Ravi P F P ....
126 Raji P F P ....
Post #1434184
Posted Friday, March 22, 2013 7:53 AM



Group: General Forum Members
Last Login: Yesterday @ 1:42 PM
Points: 14,790, Visits: 14,607
Please take a few minutes to read the first article in my signature about best practices when posting questions. We need to see ddl, sample data and desired output.

If you don't want any specific coding help and want to figure it out on your own, the best approach here is to use FOR XML.


Need help? Help us help you.

Read the article at for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1434278
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse