May 20, 2016 at 2:41 am
Instead of hard coding all the dates in pivot any samples/ideas for generating it dynamically for each month or the date range
select * from (SELECT shift_type ,shift_date1, empid1 FROM #temp1 ) as sourceTable
Pivot (MAX(shift_type) for shift_date1 in ([2015-10-01],[2015-10-02],[2015-10-03],[2015-10-04],[2015-10-05],[2015-10-06],[2015-10-07],[2015-10-08],[2015-10-09],[2015-10-10],[2015-10-11],[2015-10-12],[2015-10-13],[2015-10-14],[2015-10-15],[2015-10-16],[2015-10-17],[2015-10-18],[2015-10-19],[2015-10-20],[2015-10-21],[2015-10-22],[2015-10-23],[2015-10-24],[2015-10-25],[2015-10-26],[2015-10-27],[2015-10-28],[2015-10-29],[2015-10-30],[2015-10-31]) )
as PivotTable
May 20, 2016 at 4:16 am
gave you some dynamic pivot code last week.....can you make use of that?
http://www.sqlservercentral.com/Forums/FindPost1785575.aspx
________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply