Tickets by priority and channel

easySQL~10 min · 4 tests · helpdesk

The support lead wants a small cross-tab for the weekly review: priorities down the side, channels across the top.

Return one row per priority that appears in tickets, with:

column type meaning
priority text the ticket priority
chat integer tickets with channel = 'chat'
email integer tickets with channel = 'email'
web integer tickets with channel = 'web'
total integer all tickets with that priority, whatever the channel

Edge cases:

  • A priority with no tickets in a channel shows 0 there, not NULL.
  • If a new channel shows up, it doesn’t get a column. Its tickets still count in total.

Row order doesn’t matter.

Tables: tickets.

solution.sqlDuckDB · helpdesk

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

⌘ ↵ to run