Hi anonymous user,
Please also refer below query and check whether it is helpful to you:
; WITH CTE AS (
SELECT
CASE
WHEN IncidentTypeCode like ('[_][5-9][0-9]') OR (IncidentTypeCode like ('[5-9][0-9][a-z][0-9][0-9]') OR IncidentTypeCode like ('[5-9][0-9][a-z][0-9][0-9][a-z]'))THEN 'Fire'
WHEN IncidentTypeCode like ('[_][0-3][0-9]') OR (IncidentTypeCode like ('[0-3][0-9][a-z][0-9][0-9]') OR IncidentTypeCode like ('[0-3][0-9][a-z][0-9][0-9][a-z]') OR IncidentTypeCode in ('_NT','_ET','_ma')) THEN 'Medical'
END AS callType
,IncidentNumber
,IncidentTypeCode
,IncidentDate
FROM MV_Incident
WHERE
IncidentDate >='11/6/2020'--@IncidentDate
--AND IncidentDate <= @IncidentDate2
--AND ReportNumberAgencyID IN (@Agency)
AND FirstUnitDispatchedTime IS NOT NULL
AND IncidentTypeCode NOT IN ('_test','_SD','_BP')
)
select a.*,b.percentage
FROM CTE a
inner join
(SELECT callType,
convert(decimal(5, 2),Count(callType)* 100 / (Select Count(*) From CTE)*0.01) as percentage
FROM CTE
group by callType) b
on a.callType=b.callType
Best regards
Melissa
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Hot issues October--Users always get connection timeout problem when using multi subnet AG via listener. Especially after failover to another subnet