select ORA-01427 :单行子查询返回多行

2024年11月16日 04:02
有2个网友回答
网友(1):

(SELECT BKCTN.PNUM
FROM BKCTN
WHERE CTNSIZE = '20' AND BO.BOID = BKCTN.BOID(+) ) AS "20",
(SELECT BKCTN.PNUM
FROM BKCTN
WHERE CTNSIZE = '40' AND BO.BOID = BKCTN.BOID(+) ) AS "40",
上面这两个语句里面的查询结果是多行了。

网友(2):

Try this, it should be much more effective than yours

SELECT BO.VESSEL,
BO.VOY,
BO.ETD,
BO.PORTLOAD,
BO.PORTVIA,
BO.PORTDEST,
CASE WHEN CTNSIZE = 20 then BKCTN.PNUM ELSE NULL END,
CASE WHEN CTNSIZE = 40 then BKCTN.PNUM ELSE NULL END,
BO.GWET
FROM BO LEFT JOIN BKCTN ON BO.BOID = BKCTN.BOID