select (case when sum(分数) = 0 then null else sum(分数) end)  from #temp
能不用两次sum实现上面的语句吗?
谢谢

解决方案 »

  1.   

    select sum(case when 分数 is null  then 0 else 分数 end) from #temp
      

  2.   


    select sum(分数) from #temp;
      

  3.   

    select sum(nvl(分数,0)) from #temp;
      

  4.   

    select sum(nvl(分数,0)) from #temp;
      

  5.   

    貌似是 他要把 0 转成null 。 汗 
      

  6.   


    -- 你这好像是SQL Server的吧,这时是Oracle社区
      

  7.   


    lz 你的是mssql吧 #tempselect sum(isnull(分数,null)) from #temp
      

  8.   

    Oracle: select sum(分数) from #temp;