2013-05-01 91 views

回答

1
select s.SupnName, 
    TotalPurchase = (select sum(p.Qntty * p.PurchsePrice) 
         from ProductsTble p 
         where p.supid = s.supid), 
    TotalPayement = (select sum(c.Cashvalue) 
         from CashMovementTbl c 
         where c.supid = s.supid) 
    from SuppliersTble s; 

請確保您有索引ProductsTble(supid)CashMovementTbl(supid)

+0

感謝RichardTheKiwi,它工作正常 – 2013-05-02 10:44:55