Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 Pivot in SQL

Author  Topic 

sanjay5219
Posting Yak Master

240 Posts

Posted - 2010-07-30 : 12:13:00
Dear All,

I have this table in SQL
Date Student Att_Status
1-Jul d P
2-Jul f L
3-Jul r P
4-Jul f L
5-Jul f PL
6-Jul s P
7-Jul w P
8-Jul fg P
9-Jul h P
10-Jul d P
11-Jul s P

and i want result in this format
Student Date1 Date2 Date3 Date4 Date5 Date6 Date7 Date8
Name1 P
Name2 P
Name3 L
Name4 L
Name5 L L
Name6
Name7
Name8

Please help me

pk_bohra
Master Smack Fu Yak Hacker

1182 Posts

Posted - 2010-07-31 : 02:01:29
This can only be done using dynamic pivot.

Have a look at the following link.
http://beyondrelational.com/blogs/madhivanan/archive/2008/08/27/dynamic-pivot-in-sql-server-2005.aspx

Regards,
Bohra

I am here to learn from Masters and help new bees in learning.
Go to Top of Page

ewomack
Starting Member

33 Posts

Posted - 2010-08-05 : 13:28:28
Yes, pivot is your answer - there are loads of resources out there on this. Search the internet for SQL Pivot and you'll get boatloads.

Ed Womack
www.getmilked.com
Go to Top of Page
   

- Advertisement -