0
我正在接收空值。我怎麼能用0代替空值?我已經嘗試了pivot和select中的isNull函數,但似乎沒有更新。 TY用動態數據透視表中的0替換空值
SET @query ='SELECT * FROM(SELECT
petstoreemployee.employeefirstname as employeefirstname
,sum(petID.breed) as breeds
,Format(date, ''MMMM-yyyy'') as Month
FROM
petID, petstoreemployee
WHERE
petID.petstoreemployeeID=petstoreemployee.petstoreemployeeID and
petID.ProjectedPrjID=1
and
(petID.date >= ''2017-01-01 00:00:00:000'' AND petID.date <=
''2017-12-31 00:00:00:000'')
group by petstoreemployee.employeefirstname, Format(date,''yyyy'')
)
as d
PIVOT(
avg(breeds)
for employeefirstname
IN (' + @pet + ')
) as p'
顯示。 –
您應該可以將其添加到特定列的選擇上,如@AnthonyHorne所示顯示查詢在哪裏使用過它們 – dbajtr
嘗試select語句就像SELECT ISNULL(employeefirstname,'0')AS employeefirstname,ISNULL (品種,'0')作爲品種,\t \t \t \t \t ISNULL([Month],'''')As [Month] FROM – 2017-06-21 11:05:50