<Group by : 그룹>
group by 안에서 count를 사용하면 묶이는 것들의 갯수를 세준다
select name, count(*) from users
group by name
sum(), min(최소값을 알고 싶은 필드명), max(), avg()
<Order by : 정렬>
select name, count(*) from users
group by name
order by count(*)
*desc : 내림차순
<Where와 함께 사용하기>
select payment_method, count(*) from orders
where course_title = '웹개발 종합반'
group by payment_method
order by count(*)
<퀴즈>
1. 앱개발 종합반의 결제수단별 주문건수 세어보기
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 payment_method, count(*) as cnt from orders o
where o.course_title = '앱개발 종합반'
group by payment_method
<과제>
1. 네이버 이메일을 사용하여 앱개발 종합반을 신청한 주문의 결제수단별 주문건수 세어보기
SELECT payment_method, count(*) FROM orders
WHERE email like '%naver.com' and course_title = '앱개발 종합반'
group by payment_method