SLA breaches by priority

mediumSQL~20 min · 4 tests · helpdesk

Every ticket priority has a resolve target in slas.resolve_hours. Support leads want to know how often each priority misses it.

Only look at closed tickets (closed_at is not NULL). Open tickets haven’t finished yet, so they can’t have breached the resolve target in this report.

A closed ticket breached if it took longer than the target: closed_at is strictly later than opened_at + resolve_hours. Closing exactly on the deadline is not a breach.

Return one row per priority that has at least one closed ticket:

column type meaning
priority text the ticket priority
closed_tickets integer closed tickets with that priority
breached integer how many of those breached (0 if none)
breach_pct decimal breached / closed_tickets * 100, rounded to 1 decimal

A priority with zero breaches still gets a row, with breached = 0.

Row order doesn’t matter.

Tables: tickets, slas.

Learn the ideaRead the lesson →
solution.sqlDuckDB · helpdesk

Press ⌘ ↵ or Run to check the visible tests. Submit runs the hidden ones too. Everything runs in your browser.

⌘ ↵ to run