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