我可以获得子查询返回多个记录吗?

时间:2013-03-07 18:16:29

标签: sql oracle10g oracle11g

当我转向运行以下查询时,我收到ORA-01427: single-row subquery returns more than one row错误,不知道如何解决此问题?或者你认为我可能必须写一个游标来克服这个问题?请帮忙!

SLECT DISTINCT J.NAME
 FROM Q_jobs j, xx_po x
WHERE j.name IN
                CASE
                   WHEN x.name IS NOT NULL THEN
                      (select name from xx_po)                  
                ELSE
                      (SELECT DISTINCT j.name
                         FROM per_jobs
                        WHERE j.name not LIKE '%Des%')
                END
ORDER BY J.NAME

1 个答案:

答案 0 :(得分:1)

试试这个)

SELECT DISTINCT J.NAME
 FROM Q_jobs j, xx_po x
WHERE (x.name IS NOT NULL and j.name IN (select name from xx_po)) 
    or (x.name IS NULL and j.name IN (
                         SELECT DISTINCT j.name
                         FROM per_jobs
                         WHERE j.name not LIKE '%Des%'))
ORDER BY J.NAME