| Author |
Topic |
|
masond
Constraint Violating Yak Guru
447 Posts |
Posted - 2012-10-19 : 05:26:08
|
Hey guys I need some help with a pivot i am getting the following error message Msg 102, Level 15, State 1, Line 26Incorrect syntax near ','.my query is as follows Declare @date varchar(10)set @Date = (select dateadd(MM,-2,max(hst_date_processed))from FDMS.dbo.Fact_Financial_History) SELECT [FDMSAccountNo], [1] AS Jan, [2] AS Feb, [3] AS Mar, [4] AS Apr, [5] AS May, [6] AS June, [7] AS July, AS August, [9] AS September, [10] AS October, [11] AS November, [12] AS December FROM (Select [FDMSAccountNo], [Retail_tran_count], MONTH([Month_end_date]) as TMonth from [FDMS].[dbo].[Fact_Fee_History]) source PIVOT ( count([Retail_tran_count]) FOR TMonth where (hst_date_processed >= @dateQ) IN ( [1], [2], [3], [4], [5], [6], [7], , [9], [10], [11], [12] ) ) AS pvtMonth |
|
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2012-10-19 : 05:58:31
|
Declare @date varchar(10)set @Date = (select dateadd(MM,-2,max(hst_date_processed))from FDMS.dbo.Fact_Financial_History) SELECT [FDMSAccountNo], [1] AS Jan, [2] AS Feb, [3] AS Mar, [4] AS Apr, [5] AS May, [6] AS June, [7] AS July, AS August, [9] AS September, [10] AS October, [11] AS November, [12] AS December FROM (Select [FDMSAccountNo], [Retail_tran_count], MONTH([Month_end_date]) as TMonth from [FDMS].[dbo].[Fact_Fee_History] where (hst_date_processed >= @dateQ)) source PIVOT( count([Retail_tran_count]) FOR TMonth IN ( [1], [2], [3], [4], [5], [6], [7], , [9], [10], [11], [12] ) ) AS pvtMonth--Chandu |
 |
|
|
masond
Constraint Violating Yak Guru
447 Posts |
Posted - 2012-10-19 : 06:00:57
|
| HI Bandi i was so close, but so far :P |
 |
|
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2012-10-19 : 06:03:51
|
| Have you seen your previous posts.....--Chandu |
 |
|
|
masond
Constraint Violating Yak Guru
447 Posts |
Posted - 2012-10-19 : 06:12:31
|
| Yes , I checked them all, to get towards this answer. But as i never done one via months i got confused. But if it wasnt for you guys here, i would of been stuck |
 |
|
|
|
|
|