美好的一天。请帮助我删除Dynamic SQL Pivot中的NULLS行:
查询为:
SELECT *
FROM
(
SELECT person_id,
Name,
activity_id,
concat(activity collate database_default,
case when activity = 'maintainance'
then row_number() over (partition by Name,activity order by activitydate)
else ''
end collate database_default) as activity
FROM PesonActivities
)t
PIVOT(MAX(activity_id) FOR activity IN (
[purchased],
[installed],
[maintainance1],
[maintainance2],
[maintainance3]))p
答案 0 :(得分:1)
我只想在PIVOT之后添加一个位置
...
Where concat([purchased],[installed],[maintainance1],[maintainance2],[maintainance3])<>''