これも日付ごとにグループ化しようとしています。どうやってやるの?あるグループを 0 ~ 30、別のグループを 31 ~ 60、最後のグループを 60+ にします。SSRS でグラフを作成しており、横軸を 0-31、31-60、60+ にする必要があります。datediff の最後に "THEN P_NUMBER END) as Active_age" を追加しようとしましたが、うまくいきません。
SELECT COUNT(*) Assignment, Severity
FROM dashboard.dbo.SmTickets
WHERE Assignment IN('Crosby')
AND Severity IN(4)
AND datediff(day,Open_Time,GETDATE()) between 0 and 30
group by Assignment, Severity
UNION
SELECT COUNT(*) Assignment, Severity
FROM dashboard.dbo.SmTickets
WHERE Assignment IN('Crosby')
AND Severity IN(5)
AND datediff(day,Open_Time,GETDATE()) between 0 and 30 THEN P_NUMBER END) as Active_age
group by Assignment, Severity
UNION
SELECT COUNT(*) Assignment, Severity
FROM dashboard.dbo.SmTickets
WHERE Assignment IN('Crosby')
AND Severity IN(4)
AND datediff(day,Open_Time,GETDATE()) between 30.01 and 60
group by Assignment, Severity
UNION
SELECT COUNT(*) Assignment, Severity
FROM dashboard.dbo.SmTickets
WHERE Assignment IN('Crosby')
AND Severity IN(5)
AND datediff(day,Open_Time,GETDATE()) between 30.01 and 60
group by Assignment, Severity
UNION
SELECT COUNT(*) Assignment, Severity
FROM dashboard.dbo.SmTickets
WHERE Assignment IN('Crosby')
AND Severity IN(4)
AND datediff(day,Open_Time,GETDATE()) > 60
group by Assignment, Severity
UNION
SELECT COUNT(*) Assignment, Severity
FROM dashboard.dbo.SmTickets
WHERE Assignment IN('Crosby')
AND Severity IN(5)
AND datediff(day,Open_Time,GETDATE()) > 60
group by Assignment, Severity