当前位置: 代码迷 >> Oracle开发 >> oracle ORA-01427:单行子查询返回多个行解决方法
  详细解决方案

oracle ORA-01427:单行子查询返回多个行解决方法

热度:113   发布时间:2016-04-24 06:48:35.0
oracle ORA-01427:单行子查询返回多个行
select * from (select a.*,rownum row_num from (select a.directflag,(select sheettypename from 
sheettype where id=(select sheettypeid from moduletype where moduleid=trim(a.sheetidruleid))) 
sheettypename,(select code||'-'||abbrev from channel where channelid=a.outcomecustomer)
outcustomer,(select code||'-'||abbrev from channel where channelid=a.incomecustomer) 
incustomer,(select balancetype from balancetypeset where id=a.balancetypeid)
 balancetype,(select goodsno||'-'||goodsname from goods where goodsid=a.goodsid) 
 goodsnanme,a.quantity,a.price,a.amount,a.accdate from channelaccount a where 1=1 
 and a.incomecustomer='acd488efdcc8f4a0ae2e42ebbe8e2f72') a) where row_num>0 and row_num<=20

执行报ORA-01427:单行子查询返回多个行
求高人指点
------解决方案--------------------
把=改为in试试
------解决方案--------------------
SELECT *
  FROM (SELECT A.*, ROWNUM ROW_NUM
          FROM (SELECT A.DIRECTFLAG,
                       (SELECT SHEETTYPENAME
                          FROM SHEETTYPE
                         WHERE ID =
                               (SELECT SHEETTYPEID
                                  FROM MODULETYPE
                                 WHERE MODULEID = TRIM(A.SHEETIDRULEID))) SHEETTYPENAME,
                       (SELECT CODE 
------解决方案--------------------
 '-' 
------解决方案--------------------
 ABBREV
                          FROM CHANNEL
                         WHERE CHANNELID = A.OUTCOMECUSTOMER) OUTCUSTOMER,
                       (SELECT CODE 
------解决方案--------------------
 '-' 
------解决方案--------------------
 ABBREV
                          FROM CHANNEL
                         WHERE CHANNELID = A.INCOMECUSTOMER) INCUSTOMER,
                       (SELECT BALANCETYPE
                          FROM BALANCETYPESET
                         WHERE ID = A.BALANCETYPEID) BALANCETYPE,
                       (SELECT GOODSNO 
------解决方案--------------------
 '-' 
------解决方案--------------------
 GOODSNAME
                          FROM GOODS
                         WHERE GOODSID = A.GOODSID) GOODSNANME,
                       A.QUANTITY,
                       A.PRICE,
                       A.AMOUNT,
                       A.ACCDATE
                  FROM CHANNELACCOUNT A
  相关解决方案