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
 General SQL Server Forums
 New to SQL Server Programming
 Debug SQL Syntax II

Author  Topic 

stoolpidgeon
Starting Member

28 Posts

Posted - 2013-06-14 : 11:01:16
The following code produces the error:

Incorrect column expression: '(Case .... End)' where the error message lists the entire case statement.

SELECT AccountNo
(CASE when Cases = 0 then null else Avg(Cases / Cases+Pallets) End)
FROM SalesHistory
WHERE (Supplier='Supplier1') AND (InvoiceDate>'01/01/2013')
GROUP BY AccountNo

MuMu88
Aged Yak Warrior

549 Posts

Posted - 2013-06-14 : 11:36:23
couple of things:
you need a ',' after AccountNo in your select statement,
and include Cases, Pallets to your group by clause.
Go to Top of Page
   

- Advertisement -