스파르타코딩클럽|SQL 2주차

taeeun421·2023년 3월 19일
0

스파르타|SQL

목록 보기
2/2

SQL 2주차

group by

동일한 범주의 데이터를 묶어줌

select name, count(*) from users
group by name

order by

데이터 정렬
오름차순으로 정렬하기

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

Alias

별칭 기능

테이블 별칭

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

2주차 퀴즈 정답

select payment_method, count(*) from orders
where email like '%naver.com' and course_title = '앱개발 종합반'
group by payment_method

2주차 소감

웹개발 보다는 쉽게 느껴진다.
데이터를 보면서 코드를 적는 과정이 재미있다.

0개의 댓글