
SELECT 
    e.asset_id,
    COUNT(*) AS safety_events,
    SUM(e.safety_cost) AS total_safety_cost,
    AVG(e.safety_cost) AS avg_safety_cost
FROM events e
WHERE e.safety_cost > 0
  AND e.occurred_on IS NOT NULL
  AND e.occurred_on >= '2022-01-01'
  AND e.occurred_on <  '2025-01-01'
GROUP BY e.asset_id
ORDER BY total_safety_cost DESC;