日期:2014-05-19  浏览次数:20365 次

问一条SQL语句 在线等 马上给分 简单 !
Select   b.Money,b.Money   -   Case   cast((Select   Sum(a.SpareMoney)   from   StoreDepreciation   a   where   a.outBillNumber   =   b.BillNumber)   as   Nvarchar)   when   'NULL '   then   '444 '   else   (Select   Sum(a.SpareMoney)   from   StoreDepreciation   a   where   a.outBillNumber   =   b.BillNumber)   end,   b.*   from   vw_StoreProductOutDetail   b


为什么   如果   StoreDepreciation   表没有满足条件的记录他就显示   NULL   怎么能让他显示出来   b.Money   -   Sum(a.SpareMoney)的结果   Sum(a.SpareMoney)没有对应的记录就显示   b.Money   -   0   也就是   b.money本身   谢谢!

------解决方案--------------------
b.Money - isnull(Sum(a.SpareMoney),0)