i am writting a pivot query in sql server 2008, is this allowed? AUG, SEP ..... are not the values stored in the column recdate1 i am using the date functions to get this from this column.
)p pivot (count(ordno) for left(datename ( m , recdate1) , 3) recdate in ( [AUG] ,[SEP] ,[OCT] ,[NOV] ,[DEC] ,[JAN] ,[FEB]) ) AS PVT ;
it gives me error for this. If i dont have this just using recdate1 it works like so p pivot (count(ordno) for recdate1 in ( [AUG] ,[SEP] ,[OCT] ,[NOV] ,[DEC] ,[JAN] ,[FEB]) ) AS PVT ;
I tried but could not get it, so now seeking help.
Joined: 20 Dec 2011
Location: England
Online Status: Offline
Posts: 259
Posted: 23 Feb 2012 at 5:06am
Do you have left(datename ( m , recdate1) , 3) in your select statement for the data you're trying to pivot? If so and it still doesn't work try using the following;
)p pivot (count(ordno) for left(datename ( m , recdate1) , 3) in ( [AUG] ,[SEP] ,[OCT] ,[NOV] ,[DEC] ,[JAN] ,[FEB]) ) AS PVT ;
no i dnt have.... let me try that out will post my results here. actually original query was p pivot (count(ordno) for left(datename ( m , recdate1) , 3) in ( [AUG] ,[SEP] ,[OCT] ,[NOV] ,[DEC] ,[JAN] ,[FEB]) ) AS PVT ;
which also dnt work so i added that recdate there to check if that will make it work. my bad i dnt remove that when i posted this. Thanks for responding.
I tried but could not get it, so now seeking help.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum