想要将空值更改为零

时间:2014-09-22 13:37:33

标签: sql-server pivot

我希望避免null值,并且在每个月没有月销售时获得零

 SELECT * FROM 
 (
    SELECT DATENAME(MONTH, doa) [Month], sum(1) [Sales Count]
    From crime
    GROUP BY YEAR(doa),DATENAME(MONTH, doa)
 ) AS MontlySalesData 
 PIVOT
 ( 
   sum([Sales Count])  FOR Month 
   IN 
   (
     [January],[February],[March],[April],[May],[June],[July],
     [August],[September],[October],[November],[December]
    )
  ) AS MNamePivot  

1 个答案:

答案 0 :(得分:-3)