?
Solved

SQL command not properly ended

Posted on 2010-01-12
8
Medium Priority
?
348 Views
Last Modified: 2012-05-08
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
0
Comment
Question by:wayneburr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
8 Comments
 
LVL 11

Expert Comment

by:rajvja
ID: 26293792
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'
0
 
LVL 23

Expert Comment

by:David
ID: 26293879
I don't see how aliases will change the incorrect parsing.  However, in Oracle SQL your group-by and where clauses are reversed.
0
 

Author Comment

by:wayneburr
ID: 26293935
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
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 11

Accepted Solution

by:
rajvja earned 2000 total points
ID: 26293965
SELECT broadcastmonth, sum(projectedgross) col1, sum(projectedagencydiscount) col2, sum(projectedrepdiscount) col3, sum(projectedotherdiscount) col4, aeinitials FROM revenue
WHERE network<>'VOD' AND network<>'WEB' AND network<>'CRAL'
GROUP BY aeinitials, broadcastmonth

where clause comes before group by
0
 
LVL 15

Expert Comment

by:Devinder Singh Virdi
ID: 26296376
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.
0
 
LVL 23

Expert Comment

by:David
ID: 26296395
Glad to see y'all agreeing with me :)
0
 

Author Closing Comment

by:wayneburr
ID: 31676126
Moved the Group by after the where clause and problem solved!
0
 
LVL 15

Expert Comment

by:Devinder Singh Virdi
ID: 26296886
Yes I agree with your answer.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question