SQL Server查询来计算供应商

问题描述:

余额账户我有我的数据库表5个SQL Server查询来计算供应商

enter image description here

我想我的SQL Server查询可以这样运行了:

enter image description here

但我不知道我该怎么做,所以请帮助我。 谢谢。

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