Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Total Records by Category

EasySQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is Total Records by Category. Start with the requirements and the one table on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Microsoft analysts are reviewing product telemetry records across Microsoft 365 and Azure experiences. Write a PostgreSQL query that reports how many records belong to each category.

Requirements

  1. Group records by category and return one row per category, including records where the category is NULL.
  2. Count the records in each group and sort the output alphabetically by category, with the NULL category last.

Schema

product_events
ColumnTypeDescription
event_idPKINTEGERUnique telemetry record identifier
categoryVARCHAR(50)Microsoft product or experience category
event_nameVARCHAR(100)Name of the recorded event
event_dateDATEDate on which the event was recorded
Tablesproduct_events
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results