`

ORA-00918: column ambiguously defined

阅读更多
今天后台在执行SQL查询时报如下错误:
execerror=ORA-00918: column ambiguously defined when generage sheet data:

insert into D_SHEET_DATA (REPORT_ID,SHEET_NO,RATE_DATE,ROW_NO,COLNO1,COLNO2,COLNO3,COLNO4,COLNO5,COLNO6,COLNO7,COLNO8,COLNO9,COLNO10,COLNO11,COLNO12) select 'CTOG_04',1,'201310',rownum,a.* from (with AI as(
select cust_code as cust_code,cust_name as cust_name,sum(account_fee) as account_fee,sum(settle_fee) as settle_fee from
(select b.cust_code as cust_code,b.cust_name as cust_name,sum(account_fee) as account_fee,sum(a.settle_fee) as settle_fee
from D_IIXL_SHARE_RESULT_201310 a,STT_OBJECT b
where a.settle_carrier_id=b.cust_id
group by cust_code,cust_name
)
group by cust_code,cust_name
),

DI as
(select b.cust_code as cust_code,b.cust_name as cust_name,sum(account_fee) as account_fee,sum(a.settle_fee) as settle_fee
from D_IIXL_SHARE_RESULT_201310 a,STT_OBJECT b
where a.settle_carrier_id=7463  and a.settle_carrier_id=b.cust_id
group by cust_code,b.cust_name
)

select AI.cust_code,AI.cust_name,nvl(AI.account_fee,0),nvl(AI.settle_fee,0),
0,0,0,0,nvl(DI.account_fee,0),nvl(DI.settle_fee,0),
nvl(DI.account_fee,0),
nvl(DI.settle_fee,0)
from AI,DI
where AI.CUST_CODE = DI.cust_code(+)
) a




经查:原因是
select AI.cust_code,AI.cust_name,nvl(AI.account_fee,0),nvl(AI.settle_fee,0),
0,0,0,0,nvl(DI.account_fee,0),nvl(DI.settle_fee,0),
nvl(DI.account_fee,0),
nvl(DI.settle_fee,0)
from AI,DI
where AI.CUST_CODE = DI.cust_code(+)

在查询的时候列明重复了,导致在查询还有重复列明的临时表时会报“ORA-00918: column ambiguously defined 未明确定义列”的错误信息
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics