Link to home
Start Free TrialLog in
Avatar of Wayne Burr
Wayne BurrFlag for United States of America

asked on

SQL command not properly ended

VS2005
VB.NET
I am running the following query and am getting the error: "SQL command not properly ended".  I have changed the query in every way possible but still get the error.
Any advice would be great.
Thanks.
SELECT broadcastmonth, sum(projectedgross), sum(projectedagencydiscount), sum(projectedrepdiscount), sum(projectedotherdiscount), aeinitials FROM revenue GROUP BY aeinitials, broadcastmonth WHERE network<>'VOD' AND network<>'WEB' AND network<>'CRAL'

Open in new window

DO-ORACLE.jpg
Avatar of rajvja
rajvja
Flag of United Kingdom of Great Britain and Northern Ireland image

Hi
 Give aliases to the columns.
SELECT broadcastmonth, sum(projectedgross) Col1, sum(projectedagencydiscount) Col2, sum(projectedrepdiscount) Col3, sum(projectedotherdiscount) Col4, aeinitials FROM revenue GROUP BY aeinitials, broadcastmonth WHERE network<>'VOD' AND network<>'WEB' AND network<>'CRAL'
Avatar of David VanZandt
I don't see how aliases will change the incorrect parsing.  However, in Oracle SQL your group-by and where clauses are reversed.
Avatar of Wayne Burr

ASKER

I added the alias's and get the same results:


SELECT broadcastmonth, sum(projectedgross) col1, sum(projectedagencydiscount) col2, sum(projectedrepdiscount) col3, sum(projectedotherdiscount) col4, aeinitials FROM revenue GROUP BY aeinitials, broadcastmonth WHERE network<>'VOD' AND network<>'WEB' AND network<>'CRAL'

Open in new window

DO-ORACLE-2.jpg
ASKER CERTIFIED SOLUTION
Avatar of rajvja
rajvja
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Syntax of select statement should be like
SELECT <columns> FROM <table> WHERE <CONDITIONS>
GROUP BY <grouping column> HAVING <filetring condion of group by>

and in your case group by comes before where clause.
Glad to see y'all agreeing with me :)
Moved the Group by after the where clause and problem solved!
Yes I agree with your answer.