Oracle SQL Developer“命令未正确结束”语法错误

时间:2013-12-04 01:34:49

标签: sql oracle oracle-sqldeveloper

我正在处理一些SQL开发人员查询,并且我一直收到此错误。我看过网上但我看不清楚为什么我的语法带来“SQL命令没有正确结束错误”。错误显示在“FROM lgemployee as e”的行上。任何正确方向的帮助将不胜感激。

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;

2 个答案:

答案 0 :(得分:2)

您不能将as用作表的别名,仅在select语句中使用,例如:

select column as "alias"
from table a

从表格声明中删除as。它应该运行良好。

答案 1 :(得分:0)

我认为这是错误的括号嵌套 - 尝试

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;