Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Debug SQL Syntax II
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

United Kingdom
28 Posts

Posted - 06/14/2013 :  11:01:16  Show Profile  Reply with Quote
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

Aged Yak Warrior

549 Posts

Posted - 06/14/2013 :  11:36:23  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000