SQLSQL
#10

Filtered Aggregations with COUNT(CASE WHEN) in SQL

MediumPwC
Interview Question #10
Asked at PwC

From 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_idstatuspriority
1ResolvedHigh
2EscalatedCritical
3ResolvedLow
4OpenMedium
Expected Output Structure1 rows
total_ticketsresolved_ticketsescalated_tickets
421
Interview Context

Asked frequently in data analyst and business analyst technical rounds. Focus on clean filtering, optimal indexing usage, and unambiguous column selection.

SQLPostgreSQL 15
Ready to execute

Click "Run Query" or press Ctrl + Enter to test your query.

Output will be verified against the test dataset.

Chat with us