select * from checkins
where week=2
select payment_method, count(*) from orders
group by payment_method
select payment_method, count() from orders
where course_title = '웹개발 종합반'
group by payment_method
order by count() desc#desc써야 내림차순된다구요.
select * from users
order by name desc
#이름이 황씨부터 나오게 됨. 만약 order by 를 시간 열에다가 지정한다면,,, 시간 순서대로 정렬이 된다는 얘기임.
select payment_method, count(*) from orders
group by payment_method
select name, count(*) from users
where email like '%@gmail.com'#순서에 유의하기
group by name
select course_id, round(avg(likes)) from checkins
group by course_id
select * from orders o #이제 orders를 o라고 부르겠다.
where o.course_title = '앱개발 종합반'#o에서의 course_title를 보겠다.
select payment_method, count() as cnt from orders o
group by payment_method
order by count() desc#as 뒤에 있는 것이 count(*)의 별칭으로 지정하겠다는 의미로.
select payment_method, count() from orders
where email like '%@naver.com' and course_title = '앱개발 종합반'
group by payment_method
order by count() desc
결국
select 변수명, count (*) from 테이블명
group by
--> 엑셀에서의 subtotal... 항목별 개수인것임
(이거 사실 매우매우 유용한 기능인듯! 연대별 탄소연대 bp값 개수라던지, )
만약
select 변수명, sum(다른변수 ) from 테이블명
select랑 변수명만 넣는다면 엑셀에서 주변 변수를 다 숨기기처리하는 것과 같음.