SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

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

stoolpidgeon
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

MuMu88
Aged Yak Warrior

547 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  
 New 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.03 seconds. Powered By: Snitz Forums 2000