aboutsummaryrefslogtreecommitdiff
path: root/queries/04.sql
blob: bffae224c55580f564d961efd6037ecdb0532655 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
SET search_path TO labs;

SELECT
lab_assignment_count,
COUNT(*) AS group_count

FROM (
     SELECT
     groups.designator,
     COUNT(*) AS lab_assignment_count
     FROM groups
     INNER JOIN lab_assignments
     ON groups.id = lab_assignments.group_id
     GROUP BY groups.id
) AS ct

GROUP BY lab_assignment_count
ORDER BY lab_assignment_count;