동일한 범주를 갖는 데이터를 묶어서, 범주별 통계를 낼 때 사용.
select * from users
group by name // 이름별로 대표1명씩만 표시됨
select name, count(*) from users
group by name // 이름별로 몇명인지 표시됨.
**"group by" 할 때, 범주별 통계자료를 원한다면 select 뒤에 같은 범주명(필드명)을 입력해야
데이터를 정렬하는 것
order by count(*) //오름차순(1..10)
order by count(*) desc //내림차순(10..1)
EX)
order by likes // like를 적게 받은 순서대로 출력
select payment_method, count(*) from orders
where course_title = '앱개발 종합반'
group by payment_method;
select name, count(*) from users
where email like '%@gmail.com'
group by name
select course_id, avg(likes) from checkins
group by course_id
select * from orders o //"orders"를 줄여서 "ㅇ"
where o.course_title = '앱개발 종합반' //orders 안에 있는 "o.**"
count(*) as cnt ,,, // count(*)를 cnt로 출력