title: Return NULL as Zero from my SQL Pivot query
body: <p>I'm using SQL Server 2014 and I have a Pivot Query that runs on my database and works fine. My problem is that the certain fields have NULL in them. I want the NULLS to be replaced by a Zero.</p>
  
  <p>My query stands as follows:</p>
  
  <pre><code>(SELECT [PROPERTYCODE],
          [MARKET FINAL],
          [MARCH 2015],
          [APRIL 2015],
          [MAY 2015]          
  
  FROM (SELECT [PropertyCode],
           [MTH],
           [Room Nights],
           [Market FINAL]
  
     FROM HOLDINGS2
  
  )m
  
  PIVOT (Sum([ROOM NIGHTS])
       FOR [MTH] IN ([MARCH 2015],
                     [APRIL 2015],
                     [MAY 2015]                      
                      )) AS PVTTABLE)
   ORDER BY [PropertyCode],[Market FINAL]
  </code></pre>
  
  <p>The output looks like this:</p>
  
  <pre><code>PropertyCode   MarketFinal  March 2015  April 2015    May 2015 
  
      A            UK           245          NULL          320
  </code></pre>
  
  <p>I need the NULLS to be zeroes.</p>
  
  <p>I've tried this on the Pivot statement:</p>
  
  <pre><code>PIVOT (Sum(NULLIF[ROOM NIGHTS],0))
  </code></pre>
  
  <p>But it doesn't work. I also tried the NULLIF in the first select statement of my query next to [MARCH 2015], [APRIL 2015] AND [MAY 2015] but it still does not work!</p>