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
Author
Message
Posted Friday, March 22, 2013 4:28 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Wednesday, October 02, 2013 10:20 PM
Points: 421, Visits: 87
SELECT S.UniversityNo
,S.Name
,U.SSubjectCode
,U.IsPass
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
,S.Name
,U.SSubjectID
,U.SSubjectCode
,SU.Descriptions
,U.IsPass
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


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: 2 days ago @ 2:24 PM
Points: 11,990, Visits: 11,007
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 http://www.sqlservercentral.com/articles/Best+Practices/61537/ 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