Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Incorrect column expression
Hi,
I get the following error Incorrect column expression: 'sum(case when month(acc_Date)=1 then 1 else 0 end)'. When I try and run the following SQL in excel 'Get External Data' - however when run directly in SQL Server it works fine. Any ideas about what could be wrong? SELECT dept, Jan = sum(case when month(acc_Date)=1 then 1 else 0 end), Feb = sum(case when month(acc_Date)=2 then 1 else 0 end), Mar = sum(case when month(acc_Date)=3 then 1 else 0 end), Apr = sum(case when month(acc_Date)=4 then 1 else 0 end), May = sum(case when month(acc_Date)=5 then 1 else 0 end), Jun = sum(case when month(acc_Date)=6 then 1 else 0 end), Jul = sum(case when month(acc_Date)=7 then 1 else 0 end), Aug = sum(case when month(acc_Date)=8 then 1 else 0 end), Sep = sum(case when month(acc_Date)=9 then 1 else 0 end), Oct = sum(case when month(acc_Date)=10 then 1 else 0 end), Nov = sum(case when month(acc_Date)=11 then 1 else 0 end), Dec = sum(case when month(acc_Date)=12 then 1 else 0 end) FROM incident WHERE (acc_date BETWEEN '01-01-2004' AND '31-12-2004') GROUP BY dept |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Column sum incorrect upon subtracting | Excel Discussion (Misc queries) | |||
Incorrect Data Labels on Column Chart | Charts and Charting in Excel | |||
Excel column sumif is incorrect | Excel Discussion (Misc queries) | |||
need help with expression | Excel Discussion (Misc queries) | |||
Expression | New Users to Excel |