Oracle 中缺少右括号
Missing right parenthesis in Oracle
我有这样的查询:
select a.NPP, a.NAMA, a.JOB, a.STATUS, a.last_updated,
a.UNIT_BESARAN, a.PERIODE, a.GOAL_ID,a.USER_APPROVED,
a.DATE_APPROVED, a.USER_SUBMITTED, a.DATE_SUBMITTED
from (select a.NPP, a.NAMA, b.job, b.status, to_char(b.last_updated, 'dd-MM-yyyy HH24:MI:SS') AS last_updated,
b.periode , b.goal_id, b.USER_APPROVED, b.DATE_APPROVED, b.USER_SUBMITTED, b.DATE_SUBMITTED,
case when b.UNIT_BESARAN is null then a.UNIT_BESARAN else b.UNIT_BESARAN end UNIT_BESARAN
from OL_PEGAWAI_DAILY a left join PFM_GOAL_HEADER b on a.PERSON_ID=b.PERSON_ID and b.last_status=1 and
b.periode = '2015' and b.status is null order by b.STATUS asc) a where UNIT_BESARAN like 'DIVISI SOLUSI % KEAMANAN TEKNOLOGI INFORMASI'
and a.status is null and npp not in (
--here subquery
select f.NPP from (select f.NPP, g.status, g.goal_id,
case when g.UNIT_BESARAN is null then f.UNIT_BESARAN else g.UNIT_BESARAN end UNIT_BESARAN
from OL_PEGAWAI_DAILY f left join PFM_GOAL_HEADER g on f.PERSON_ID=g.PERSON_ID and g.last_status=1 and
g.periode = '2015' and g.status='2' and g.job is not null and g.last_updated is not null order by g.STATUS asc) f
where UNIT_BESARAN like 'DIVISI SOLUSI %' and f.status is not null order by goal_id asc
) order by goal_id asc
在子查询中,当我尝试 运行 它时,我没有收到任何错误。当我尝试 运行 所有查询时,我收到如下错误:
ORA-00907: missing right parenthesis
Oracle 不允许在与 in
运算符一起使用的子查询中使用 order by
子句(大概是因为它毫无意义 - in
运算符不关心顺序).不幸的是,使用它会产生 ORA-00907 而不是一些 straight-forward 错误,它实际上解释了你做错了什么。
长话短说 - 从 in
运算符中使用的查询中删除 order by goal_id asc
,您应该没问题。
我有这样的查询:
select a.NPP, a.NAMA, a.JOB, a.STATUS, a.last_updated,
a.UNIT_BESARAN, a.PERIODE, a.GOAL_ID,a.USER_APPROVED,
a.DATE_APPROVED, a.USER_SUBMITTED, a.DATE_SUBMITTED
from (select a.NPP, a.NAMA, b.job, b.status, to_char(b.last_updated, 'dd-MM-yyyy HH24:MI:SS') AS last_updated,
b.periode , b.goal_id, b.USER_APPROVED, b.DATE_APPROVED, b.USER_SUBMITTED, b.DATE_SUBMITTED,
case when b.UNIT_BESARAN is null then a.UNIT_BESARAN else b.UNIT_BESARAN end UNIT_BESARAN
from OL_PEGAWAI_DAILY a left join PFM_GOAL_HEADER b on a.PERSON_ID=b.PERSON_ID and b.last_status=1 and
b.periode = '2015' and b.status is null order by b.STATUS asc) a where UNIT_BESARAN like 'DIVISI SOLUSI % KEAMANAN TEKNOLOGI INFORMASI'
and a.status is null and npp not in (
--here subquery
select f.NPP from (select f.NPP, g.status, g.goal_id,
case when g.UNIT_BESARAN is null then f.UNIT_BESARAN else g.UNIT_BESARAN end UNIT_BESARAN
from OL_PEGAWAI_DAILY f left join PFM_GOAL_HEADER g on f.PERSON_ID=g.PERSON_ID and g.last_status=1 and
g.periode = '2015' and g.status='2' and g.job is not null and g.last_updated is not null order by g.STATUS asc) f
where UNIT_BESARAN like 'DIVISI SOLUSI %' and f.status is not null order by goal_id asc
) order by goal_id asc
在子查询中,当我尝试 运行 它时,我没有收到任何错误。当我尝试 运行 所有查询时,我收到如下错误:
ORA-00907: missing right parenthesis
Oracle 不允许在与 in
运算符一起使用的子查询中使用 order by
子句(大概是因为它毫无意义 - in
运算符不关心顺序).不幸的是,使用它会产生 ORA-00907 而不是一些 straight-forward 错误,它实际上解释了你做错了什么。
长话短说 - 从 in
运算符中使用的查询中删除 order by goal_id asc
,您应该没问题。