oracle SQL:
select
t.chargetype,
sum(i.INVOICEAMOUNT) as INVOICEAMOUNTsum,       
sum(i.PAYMENTAMOUNT) as PAYMENTAMOUNTsum ,
sum(i.PAYMENTAMOUNT)-sum(i.INVOICEAMOUNT) as chargediffer
from
TBT_RKN_INFORMATION t ,
tbt_rkn_invoice i
where 
i.RECKONINGID = t.RECKONINGID and
chargediffer<>0
group by t.chargetype运行提示 chargediffer标识符无效,要怎么解决?

解决方案 »

  1.   

    " TBT_RKN_INFORMATION t , tbt_rkn_invoice i " 两张表中有字段chargediffer吗?如有,应注明是t.chargediffer,还是i.chargediffer?
    如没有,是你写错了。
      

  2.   

    没有这个字段,我用as来的,类似的SQL我在其它表也用过,一样不行
      

  3.   

    本来这个SQL有100来行,我是精简给大家看得
      

  4.   

    where里不能用别名的,只有ORDER BY可以用改成这样
    select 
    t.chargetype, 
    sum(i.INVOICEAMOUNT) as INVOICEAMOUNTsum,       
    sum(i.PAYMENTAMOUNT) as PAYMENTAMOUNTsum , 
    sum(i.PAYMENTAMOUNT)-sum(i.INVOICEAMOUNT) as chargediffer 
    from 
    TBT_RKN_INFORMATION t , 
    tbt_rkn_invoice i 
    where 
    i.RECKONINGID = t.RECKONINGID and 
    group by t.chargetype 
    having sum(i.PAYMENTAMOUNT)-sum(i.INVOICEAMOUNT) <>0