用isnull()来解决ISNULL
使用指定的替换值替换 NULL。语法
ISNULL ( check_expression , replacement_value ) 参数
check_expression将被检查是否为 NULL的表达式。check_expression 可以是任何类型的。replacement_value在 check_expression 为 NULL时将返回的表达式。replacement_value 必须与 check_expresssion 具有相同的类型。 返回类型
返回与 check_expression 相同的类型。注释
如果 check_expression 不为 NULL,那么返回该表达式的值;否则返回 replacement_value。示例
A. 将 ISNULL 与 AVG 一起使用
下面的示例查找所有书的平均价格,用值 $10.00 替换 titles 表的 price 列中的所有 NULL 条目。USE pubs
GO
SELECT AVG(ISNULL(price, $10.00))
FROM titles
GO下面是结果集:-------------------------- 
14.24     

解决方案 »

  1.   

    应该是null值的影响,null与任何值的运算结果都为null试试改为:select a.sp_id,a.sp_name ,b.pf_mount,b.pf_money,c.ls_mount,c.ls_money,
    isnull(b.pf_mount,0)+isnull(c.ls_mount,0) as zmount,
    isnull(b.pf_money,0)+isnull(c.ls_money,0) as zmoney
    from shpxx a left outer join 
      (select sp_id,pf_mount as pf_mount,pf_money as pf_money 
    from pfxx group by sp_id) b on a.sp_id=b.sp_id left outer join 
      (select sp_id,ls_mount as ls_mount,ls_money as ls_money 
    from lsxx group by sp_id) c on a.sp_id=c.sp_id
      

  2.   

    select a.sp_id,a.sp_name ,isnull(b.pf_mount,0),isnull(b.pf_money,0),isnull(c.ls_mount,0),isnull(c.ls.money,0),
    isnull(b.pf_mount,0)+isnull(c.ls_mount,0) as zmount,isnull(b.pf_money,0)+isnull(c.ls_money,0) as zmoney
    from shpxx a left outer join 
      (select sp_id,pf_mount as pf_mount,pf_money as pf_money 
    from pfxx group by sp_id) b on a.sp_id=b.sp_id left outer join 
      (select sp_id,ls_mount as ls_mount,ls_money as ls_money 
    from lsxx group by sp_id) c on a.sp_id=c.sp_id