user2053184
user2053184

Reputation:

Oracle SQL Developer "command not properly ended" error in syntax

I'm working on some SQL developer queries and I keep getting this error. Ive looked online but I cant see to see why my syntax bring a "SQL command not properly ended error". The error is showing up on the line that has "FROM lgemployee as e". Any help in the right direction would be greatly appreciated.

SELECT e.emp_num, emp_lname, emp_fname, sal_amount
FROM lgemployee as e
NATURAL JOIN lgsalary_history
WHERE sal_from = (SELECT min(sal_from))
FROM lgsalary_history as s2
WHERE (e.emp_num = s2.emp_num)
ORDER BY e.emp_num;

Upvotes: 0

Views: 1706

Answers (2)

tilley31
tilley31

Reputation: 688

You can't use as as alias for tables, only in select statements, for instance:

select column as "alias"
from table a

Remove the as from your table declarations. It should run fine.

Upvotes: 1

antlersoft
antlersoft

Reputation: 14786

I think it's just wrong parentheses nesting -- try

SELECT e.emp_num, emp_lname, emp_fname, sal_amount
FROM lgemployee as e
NATURAL JOIN lgsalary_history
WHERE sal_from = (SELECT min(sal_from)
FROM lgsalary_history as s2
WHERE (e.emp_num = s2.emp_num))
ORDER BY e.emp_num;

Upvotes: 0

Related Questions