Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: pivot query Post Reply Post New Topic
Author Message
Rshekdar
Newbie
Newbie
Avatar

Joined: 22 Feb 2012
Location: Singapore
Online Status: Offline
Posts: 7
Quote Rshekdar Replybullet Topic: pivot query
     Posted: 22 Feb 2012 at 8:50pm
hello all,

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.
IP IP Logged
rkrowland
Senior Member
Senior Member
Avatar

Joined: 20 Dec 2011
Location: England
Online Status: Offline
Posts: 259
Quote rkrowland Replybullet 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 ;
Regards,
Ryan.


Edited by rkrowland - 23 Feb 2012 at 5:09am
IP IP Logged
Rshekdar
Newbie
Newbie
Avatar

Joined: 22 Feb 2012
Location: Singapore
Online Status: Offline
Posts: 7
Quote Rshekdar Replybullet Posted: 23 Feb 2012 at 8:47pm
hello Rowland,

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.
IP IP Logged
Rshekdar
Newbie
Newbie
Avatar

Joined: 22 Feb 2012
Location: Singapore
Online Status: Offline
Posts: 7
Quote Rshekdar Replybullet Posted: 23 Feb 2012 at 10:49pm
that worked. using left(datename......) in select statement worked actually.
I tried but could not get it, so now seeking help.
IP IP Logged
Printable version Printable version

Forum Jump
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