ORA-00933: SQL 命令在 Oracle 数据库中未正确结束
ORA-00933: SQL command not properly ended in oracle database
select
*
from
(
select
rating,
avg(age) as avgage
from
sailors
group by
rating
) as temp
where
temp.avgage = (
select
min(temp.avgage)
from
temp
);
当我尝试运行上述命令时,出现以下错误
ORA-00933: SQL command not properly ended
水手 table 看起来像这样
Sailors Table
你能告诉我为什么会出现这个错误吗?
Table Oracle 中的别名没有 AS
(列可以,但不是必须)。
因此:
No : ) as temp
Yes: ) temp
自 ORA-00942 起:temp
在子查询中 不可访问 。但是,如果您将它(temp
)用作 CTE 或内联视图(因此它是整个查询可读的 source),那么它应该没问题.像这样:
with temp as
(select rating, avg(age) as avgage
from sailors
group by rating
)
select *
from temp a
where a.avgage = (select min(b.avgage)
from temp b
);
select
*
from
(
select
rating,
avg(age) as avgage
from
sailors
group by
rating
) as temp
where
temp.avgage = (
select
min(temp.avgage)
from
temp
);
当我尝试运行上述命令时,出现以下错误
ORA-00933: SQL command not properly ended
水手 table 看起来像这样 Sailors Table
你能告诉我为什么会出现这个错误吗?
Table Oracle 中的别名没有 AS
(列可以,但不是必须)。
因此:
No : ) as temp
Yes: ) temp
自 ORA-00942 起:temp
在子查询中 不可访问 。但是,如果您将它(temp
)用作 CTE 或内联视图(因此它是整个查询可读的 source),那么它应该没问题.像这样:
with temp as
(select rating, avg(age) as avgage
from sailors
group by rating
)
select *
from temp a
where a.avgage = (select min(b.avgage)
from temp b
);