SQL 연습문제 4-1

회원(users) 테이블에서 전체 유저의 평균연령을 조회하세요.

결과 예시

스크린샷 2023-01-12 오후 1.40.57.png

select avg(age)
from `thelook_ecommerce.users`

SQL 연습문제 4-2

회원(users) 테이블에서 여성 유저의 평균연령을 조회하세요.

결과 예시

스크린샷 2023-01-12 오후 1.41.33.png

select avg(age)
from `thelook_ecommerce.users`
where gender='F'

SQL 연습문제 4-3

회원(users) 테이블에서 국가별 가입자수를 조회하세요.

결과 예시

스크린샷 2023-01-12 오후 1.42.04.png

select country, count(id) as country_user_count
from `thelook_ecommerce.users`
group by country;

SQL 연습문제 4-4

회원(users) 테이블에서 남성 유저의 국가별 가입자 수를 조회하세요.

결과 예시

스크린샷 2023-01-12 오후 1.42.42.png

select country, count(id) as country_user_count
from `thelook_ecommerce.users`
where gender = 'M'
group by country;