Study/개발일지
[엑셀보다쉬운sql]강의 2주차
아이바
2023. 5. 3. 21:04
성씨별 회원수를 Group by로 쉽게 구해보기
select name, count(*) from users group by name;
select name, count(*) from users
group by name;
- from users: users 테이블 데이터 전체를 가져옵니다.
- group by name: users 테이블 데이터에서 같은 name을 갖는 데이터를 합쳐줍니다.
- select name, count(*): name에 따라 합쳐진 데이터가 각각 몇 개가 합쳐진 것인지 세어줍니다.
group by를 사용해서 '신'씨를 가진 데이터가 몇 개인지 살펴보기
select name, count(*) from users group by name;
앱개발 종합반의 결제수단별 주문건수 세어보기
select payment_method, count(*) from orders where course_title = "앱개발 종합반" group by payment_method;
네이버 이메일을 사용하여 앱개발 종합반을 신청한 주문의 결제수단별 주문건수 세어보기
select payment_method, count(*) from orders where email like '%naver.com' and course_title = '앱개발 종합반' group by payment_method
728x90