select * from c left join b on b.hetonghao=c.hetonghao
inner join a on a.hetonghao=b.hetonghao
where (a.danjia*b.shuliang) <>b.huikuanjine
------解决方案--------------------
SQL code
select c.hetongNo
from c join (select hetongNo,sum(price*num) amount from a group by hetongNo) b on c.hetongNo = b.hetongNo
join (select hetongNo,sum(reAmount) amount from b group by hetongNo) d on c.hetongNo = d.hetongNo
where b.amount <> c.amount
group by c.hetongNo
------解决方案--------------------
SQL code
select distinct c.合同号 from c left join a on c.合同号=a.合同号 left join b on c.合同号=b.合同号
group by c.合同号
having sum(a.单价*数量)<>sum(b.回款金额)
------解决方案-------------------- 这个错了,呵呵。
------解决方案-------------------- select distinct c.合同号 from a,b,c where a.合同号=b.合同号 and b.合同号=c. 合同号 and b.回款金额 NOT (a.单价 * a.数量)
------解决方案--------------------
select distinct a.Contractno from A where a.Contractno not in ( select d.Contractno( (select b.Contractno,sum(b.price*b.num) as totalb from B b group by b.Contractno) d left join (select c.Contractno,sum(c.backprice) as totalc from C c group by c.Contractno) e on e.Contractno = d.Contractno where d.totalb=e.totalc )