동일한 범주의 데이터를 묶어줌
select name, count(*) from users
group by name
데이터 정렬
오름차순으로 정렬하기
select name, count(*) from users
group by name
order by count(*)
내림차순으로 정렬하기
select name, count(*) from users
group by name
order by count(*) desc
select min(likes) from checkins
select max(likes) from checkins
select avg(likes) from checkins
반올림
select round(avg(likes),1) from checkins
select count(likes) from checkins
별칭 기능
테이블 별칭
select * from orders o
where o.course_title = '앱개발 종합반'
필드 별칭 : as
select payment_method, count(*) as cnt from orders o
where o.course_title = '앱개발 종합반'
group by payment_method
select payment_method, count(*) from orders
where email like '%naver.com' and course_title = '앱개발 종합반'
group by payment_method
웹개발 보다는 쉽게 느껴진다.
데이터를 보면서 코드를 적는 과정이 재미있다.