replace null values in sql pivot

前端 未结 1 505
粉色の甜心
粉色の甜心 2021-01-17 17:33

I have the following query :

SELECT *
FROM Table1
PIVOT
(
  SUM(Value)
  FOR [Period] IN ([06/1/2007],[07/1/2007])
)
AS p

Some of the rows

相关标签:
1条回答
  • 2021-01-17 17:59

    Ohh, I was using ISNULL in the wrong place.

    the query should look like this:

    SELECT ID,ISNULL([06/1/2007],0), ISNULL([07/1/2007],0)
    FROM Table1
    PIVOT
    (
      SUM(Value)
      FOR [Period] IN ([06/1/2007],[07/1/2007])
    )
    AS p
    
    0 讨论(0)
提交回复
热议问题