当前位置: 代码迷 >> ASP.NET >> 问一条SQL语句 马上给分 简单
  详细解决方案

问一条SQL语句 马上给分 简单

热度:2841   发布时间:2013-02-25 00:00:00.0
问一条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)
  相关解决方案