Link to home
Start Free TrialLog in
Avatar of Larry Brister
Larry BristerFlag for United States of America

asked on

SQL Pivot

I have a table with the following columns and example data

taskName     Number      runDate
tsk1                 1000         2012-08-21 11:53:10.000
etc...


I want to do a select based on last 2 weeks and return the following considering that today is 8/21/2012

TaskName       8/21    8/20     8/19  etc
tsk1                1000     56        253
tsk2                 0         2000     300
etc...
Avatar of vasto
vasto
Flag of United States of America image

You need to convert your date to varchar (Month/Year) and  implement dynamic pivot table as it is shown here:
http://www.simple-talk.com/blogs/2007/09/14/pivots-with-dynamic-columns-in-sql-server-2005/
ASKER CERTIFIED SOLUTION
Avatar of keyu
keyu
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Larry Brister

ASKER

Long...but a viable solution