Codington
0 of 8 problems solved • 0%

Exercise prompt

Count Runs for Every Service

GROUP BY gives each service its own count. Try the example with COUNT(*). Look at search: LEFT JOIN keeps a row for it even though the deployment ID is NULL. Which column can you count to measure actual runs?

Example

SELECT s.name AS service, COUNT(*) AS joined_rows FROM services AS s LEFT JOIN deployments AS d ON s.id = d.service_id GROUP BY s.name;

Your task

Start from services and use LEFT JOIN to report each service name as service and its number of deployments as run_count. Show one row per service and zero for a service that has never run.

Opening the database…