Wayne Burr
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.
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'
DO-ORACLE.jpg
I don't see how aliases will change the incorrect parsing. However, in Oracle SQL your group-by and where clauses are reversed.
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'
DO-ORACLE-2.jpg
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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 :)
ASKER
Moved the Group by after the where clause and problem solved!
Yes I agree with your answer.
Give aliases to the columns.
SELECT broadcastmonth, sum(projectedgross) Col1, sum(projectedagencydiscoun