如下代码
select ...,(b.quantity-isnull(sum(c.quantity),0))*b.unit_price as totalprice from table b left join table2 c on ... where ... group by ...select ...,(b.quantity-isnull(sum(c.q