码迷,mamicode.com
首页 > 其他好文 > 详细

ORA-00918 column ambiguously defined

时间:2015-06-21 02:04:57      阅读:139      评论:0      收藏:0      [点我收藏+]

标签:oracle   sql   数据库   

11.2.0.1中同样的一个SQL能正常执行:
 select  -- 代金券收入
         ‘VOUCHER‘ AS SUMMODE,
          a.billingdate,
          a.rdate,
          a.storeroomid,
       a.accountscode,
       g.accountsname,
       I.RELATED,--业务内容
       CASE WHEN I.RELATED = ‘HQ_billcheckout‘ THEN H.DICTIONARYCODE ELSE NULL END AS PAYMENTCODE,
       CASE WHEN I.RELATED = ‘HQ_billcheckout‘ THEN H.DICTIONARYNAME ELSE NULL END AS PAYMENT,--收款方式名称
       CASE WHEN I.RELATED = ‘HQ_billcheckout‘ THEN h.statistic_class ELSE NULL END AS statistic_class,  --收款方式分类
       nvl(a.debit,0)-nvl(a.credit,0) as tradeMoney,
       0 as StandDealTotalm,
       0 as DiscDealTotal,
       0 as OtheDealTotal
  from HQ_accountingbooks a
  inner join m_coupon_grant d on a.bid=nvl(d.bid,d.cgid)
  inner join HQ_accounts g on a.accountscode=g.accountscode
  LEFT JOIN (SELECT A1.* FROM HQ_DATADICTIONARY A1 WHERE A1.DICTIONARYTYPE=1) H ON g.ACCOUNTSCODE=H.ACCOUNTCODE
  inner join HQ_billcase_accounts i on d.billsubcase=i.billsubcase and a.accountscode=i.accountscode
where BILLSUBCASE = 5201;
在11.2.0.4中报错:
ORA-00918: column ambiguously defined
对比了下,两个数据库中所有对应的表表结构都一样,为什么在11.2.0.1中能正常执行,在11.2.0.4中执行不了?
发现这个SQL中有2个表中都有BILLSUBCASE这一列:
select BILLSUBCASE from HQ_accountingbooks;
select BILLSUBCASE from m_coupon_grant;
于是指定a.BILLSUBCASE = 5201;即解决。
看来11.2.0.4中对SQL的语法要求更严格。

ORA-00918 column ambiguously defined

标签:oracle   sql   数据库   

原文地址:http://blog.csdn.net/zhou1862324/article/details/46576253

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!