The same status can appear in several environments. Two grouping columns produce one row for each pair that occurs in the log. The example splits each service ID by status.
SELECT service_id, status, COUNT(*) AS runs
FROM deployments
GROUP BY service_id, status;Count runs for every observed combination of environment and status. Return those two columns followed by run_count. Sort first by environment, then by status, both alphabetically.