Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 356
  • Last Modified:

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
0
wayneburr
Asked:
wayneburr
  • 2
  • 2
  • 2
  • +1
1 Solution
 
rajvjaCommented:
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
 
DavidSenior Oracle Database AdministratorCommented:
I don't see how aliases will change the incorrect parsing.  However, in Oracle SQL your group-by and where clauses are reversed.
0
 
wayneburrAuthor Commented:
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
Industry Leaders: 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!

 
rajvjaCommented:
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
 
Devinder Singh VirdiLead Oracle DBA TeamCommented:
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
 
DavidSenior Oracle Database AdministratorCommented:
Glad to see y'all agreeing with me :)
0
 
wayneburrAuthor Commented:
Moved the Group by after the where clause and problem solved!
0
 
Devinder Singh VirdiLead Oracle DBA TeamCommented:
Yes I agree with your answer.
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now