Service Roll Call

An easy SQL interview practice problem on DataDriven. Write the query and run it against a real database, with instant feedback.

Domain
SQL
Difficulty
easy
Seniority
L3
Asked in
Southwest Airlines

Problem

The SRE team wants a quick count of how many unique services are being monitored by health checks.

The mesh is sprawling. Find out exactly how many services are actually running.

Tables

svc_health

Columns: check_id INTEGER, svc_name TEXT, status TEXT, latency REAL, uptime REAL, checked TEXT, region TEXT

svc_health: 10 of 200 rows
check_idsvc_namestatuslatencyuptimecheckedregion
137payment-apidegraded3.697.032026-02-02 01:05:00us-west-2
174user-svcunhealthy6.794.062026-03-03 02:10:00eu-west-1
211search-apitimeout9.891.092026-04-04 03:15:00ap-south-1
248gatewayHealthy12.998.122026-05-05 04:20:00eu-central-1
285notif-svcDEGRADED1695.152026-06-06 05:25:00us-east-1
322ml-servinghealthy19.192.182026-07-07 06:30:00us-west-2
359cache-svcdegradedNULL99.212026-08-08 07:35:00eu-west-1
396queue-workerunhealthy25.396.242026-09-09 08:40:00ap-south-1
433cron-svctimeout28.493.272026-01-10 09:45:00eu-central-1
470auth-svcHealthy31.590.32026-02-11 10:50:00us-east-1

Expected output

First 1 of 1 rows
unique_services
15

Worked solution and explanation

Why this problem exists in real interviews

This is the simplest COUNT(DISTINCT) query. It screens for whether you know how to count unique values in a column.


Break down the requirements

Step 1: Count unique services

COUNT(DISTINCT svc_name) returns the number of unique service names in the table.


The solution

Simple distinct count
SELECT COUNT(DISTINCT svc_name) AS unique_services
FROM svc_health

Common follow-up questions