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 Programming
 Pivot table is ms sql express and i am not a good

Author  Topic 

bfeucht
Starting Member

1 Post

Posted - 2012-08-15 : 16:29:41
I am trying to write a sql statement in MS SQL Express that turns a flat table into a pivot table.

Sample data:


project id Date Amount
1 10/1/2012 10
1 11/1/2012 10
1 12/1/2012 10
1 1/1/2013 10
1 1/2/2013 10
1 1/3/2013 10
1 1/4/2013 10
1 1/5/2013 10
1 1/6/2013 10
1 1/7/2013 10
1 1/8/2013 10


And Returns this;

Project id 10/1/2012 11/1/2012 12/1/2012 1/1/2013 2/1/2013 3/1/2013
1 10
1 10
1 10
1 10
1 10
1 10


The Dates are dynmanic


sdsdsd

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-08-15 : 22:29:54
see

http://dotnetgalactics.wordpress.com/2009/10/23/using-sql-server-20052008-pivot-on-unknown-number-of-columns-dynamic-pivot/

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

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2012-08-16 : 07:36:12
Also refer
http://beyondrelational.com/modules/2/blogs/70/posts/10840/dynamic-pivot-in-sql-server-2005.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -