【问题标题】:OraOLEDB : ORA-01427: single-row subquery returns more than one rowOraOLEDB : ORA-01427: 单行子查询返回多于一行
【发布时间】:2014-03-15 04:11:09
【问题描述】:

在我的数据块中运行此子查询时收到 SQL 错误

我正在尝试让员工恢复其在上一个雇主的职位

这是我的查询:

(select
(case
WHEN

(select
distinct
'x'
from aprehis a
where
donor.pidm = a.aprehis_pidm
and a.aprehis_empr_pidm is null
and trunc(a.aprehis_to_date) =

(select max(trunc(aprehis_to_date))
from aprehis b
where b.aprehis_pidm = donor.pidm
and trunc (b.aprehis_to_date) is not null))= 'x'
THEN
(select distinct (aprehis_empl_position)
from aprehis where
aprehis_pidm = donor.pidm
and aprehis_empr_name =

(select max(aprehis_empr_name)
from aprehis d
where d.aprehis_pidm = donor.pidm
and trunc(d.aprehis_to_date) =

(select max(trunc(aprehis_to_date))
from aprehis c
where c.aprehis_pidm = donor.pidm
and trunc (c.aprehis_to_date) is not null)))

ELSE

 (select distinct (aprehis_empl_position)
 from aprehis where aprehis_pidm = donor.pidm
 and aprehis_empr_name =
 (select spriden_last_name
 from spriden
  where spriden_change_ind is null
  and spriden_pidm =

 (select max(aprehis_empr_pidm) from aprehis e
  where e.aprehis_pidm = donor.pidm
  and e.aprehis_empr_pidm is not null
   and trunc(e.aprehis_to_date)=(select max(trunc(aprehis_to_date))
  from aprehis b

任何帮助将不胜感激。

非常感谢

【问题讨论】:

  • 这不是您的完整查询。据我所知,有五个(!)未闭合的括号。一些建议:(1) 编辑问题以包含您的完整查询,(2) 缩进查询以使子查询结构更明显,(3) 为我们提供一些重现问题的示例数据。
  • 完整查询太长,无法插入...这只是我需要返回的字段之一。
  • 如果完整的查询太长而无法插入,我们怎么知道问题不在您未与我们共享的查询部分?

标签: sql oracle


【解决方案1】:

请尝试在两个不同的地方更改以下行: 选择不同的(aprehis_empl_position)

到: 选择 MAX (aprehis_empl_position)

【讨论】:

    猜你喜欢
    • 2017-11-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多