Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Command not properly ended?

I am using a SQL statement with a Temporary relation, and am getting the error ORA-009933: SQL command not properly ended

I don't see anything wrong with the statement, so any assistance is greatly appreciated. The statement is:

SELECT Temp.name,
       Temp.AvgSalary
FROM   (SELECT A.aid,
               A.aname       AS name,
               AVG(E.salary) AS AvgSalary
        FROM   Aircraft A,
               Certified C,
               Employees E) AS Temp; 

Thanks

like image 254
Paul Woidke Avatar asked Mar 21 '12 19:03

Paul Woidke


People also ask

How do I fix SQL not properly ended?

To correct this issue, simply go back to the end of the phrase and remove the ORDER BY clause. Be sure to go back to the line prior to the ORDER BY clause and re-insert the statement-ending semi-colon. Another case where the ORA-00933 can occur is when attempting to include an ORDER BY clause with a DELETE statement.

How do you end a SQL command?

Ending a SQL Command You can end a SQL command in one of three ways: with a semicolon (;) with a slash (/) on a line by itself.


2 Answers

oracle does not support as for table aliases, only for column aliases and they are optional for that use => delete all as keywords ;)

like image 196
Aprillion Avatar answered Oct 18 '22 19:10

Aprillion


You shouldn't put the AS temp. When putting alias to a table (or subquery) you should only write the alias. This should work:

SELECT Temp.name, Temp.AvgSalary 
FROM ( SELECT A.aid, A.aname AS name, AVG(E.salary) AS AvgSalary 
       FROM Aircraft A, Certified C, Employees E)  Temp;

Best regards,

like image 36
Christian Vielma Avatar answered Oct 18 '22 21:10

Christian Vielma