Advertisement
DataCCIW

Protection Profile Active Record Count

May 8th, 2024
786
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.48 KB | None | 0 0
  1. DECLARE @TotalActiveRecords INT  = (SELECT COUNT(*) FROM Person WHERE RecordStatusValueId = 3)  -- Active Records
  2.  
  3. SELECT
  4.     CASE AccountProtectionProfile
  5.         WHEN 0 THEN 'Low'
  6.         WHEN 1 THEN 'Medium'
  7.         WHEN 2 THEN 'High'
  8.         WHEN 3 THEN 'Extreme' END,
  9.     COUNT(*) AS [Record Count],
  10.     CAST(((COUNT(*) * 100.0) / @TotalActiveRecords) AS DECIMAL(5, 2)) AS [Percent]
  11. FROM Person
  12. WHERE RecordStatusValueId = 3 -- Active
  13. GROUP BY AccountProtectionProfile
  14.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement