SQL
All Top 50 SQL Interview Questions#10
Filtered Aggregations with COUNT(CASE WHEN) in SQL
MediumPwCInterview Question #10
Asked at PwCFrom a `tickets` table, return a single summary row showing `total_tickets`, `resolved_tickets`, and `escalated_tickets` using conditional aggregation.
Input Table: tickets
4 rows preview| ticket_id | status | priority |
|---|---|---|
| 1 | Resolved | High |
| 2 | Escalated | Critical |
| 3 | Resolved | Low |
| 4 | Open | Medium |
Expected Output Structure1 rows
| total_tickets | resolved_tickets | escalated_tickets |
|---|---|---|
| 4 | 2 | 1 |
Interview Context
Asked frequently in data analyst and business analyst technical rounds. Focus on clean filtering, optimal indexing usage, and unambiguous column selection.
PostgreSQL 15
Ready to execute
Click "Run Query" or press Ctrl + Enter to test your query.
Output will be verified against the test dataset.