Skip to content · ⁨본문 바로가기⁩

Grouping with GROUP BY · ⁨GROUP BY를 이용한 그룹화⁩

Grouping rows with GROUP BY

An aggregate like AVG normally summarises the whole table into one number. GROUP BY splits the rows into groups that share a value, and gives one summary row per group:

SELECT form, COUNT(*) AS n, ROUND(AVG(score), 2) AS avg_score
FROM student
GROUP BY form;

This gives one row for each form, with that form's count and average.

GROUP BY collapses rows that share a value into one row per group, summing the rest

Handout · ⁨교재 자료⁩

Log in or create account · ⁨로그인 또는 계정 만들기⁩

IGCSE, A-Level & AP