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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Rows into Columns

Author  Topic 

vivo
Starting Member

24 Posts

Posted - 2010-06-02 : 00:39:15
select b.employeeid,a.name,a.department,a.employeeno,
payday,wperiod
from employee a, b
where a.id=b.employeeid
and payday between '04/07/2010' and '04/16/2010'

there are more than one record for each employeeid with different payday and different wperiod.

I want to make payday rows as columns . Related wperiod are under each those payday columns.

empID ..... 01/01/2010.. 02/01/2010..02/01/2010
123 wperiod .. wperiod .. wperiod
456 wperiod .. wperiod .. wperiod

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-06-05 : 07:08:47
see
http://sqlblogcasts.com/blogs/madhivanan/archive/2008/08/27/dynamic-pivot-in-sql-server-2005.aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -