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
 Other SQL Server Topics (2005)
 Range in PIVOT clause

Author  Topic 

CXXXV
Starting Member

12 Posts

Posted - 2009-05-26 : 15:14:26
I have the following statement working fine:

SELECT *
FROM
(SELECT M.MEMBER_ID, M.LAST_NAME, M.FIRST_NAME, S.QTY, S.DATE, ENSURE
FROM (Schedule As S JOIN Members As M ON S.MEMBER_ID = M.MEMBER_ID)) ps
PIVOT(SUM (QTY) FOR DATE IN ([05/18/2009])) AS Q


However, what I need is to be able to define a range in the IN clause.

Something like >=4/1/2009 and <=5/31/2009

Any help will be greatly appreciated.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-05-26 : 16:21:21
You will have to explicit write all dates to pivot for.
This can be done dynamically. There are lot of examples of this here at SQLTeam.


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -