최종적인 데이터에 필터를 더 걸어주는 함수
SELECT
country,
COUNT(id) AS country_user_count
FROM `thelook_ecommerce.users`
GROUP BY country
having country_user_count <= 3000
SELECT
country, city,
COUNT(id) AS country_user_count
FROM `thelook_ecommerce.users`
GROUP BY country, city
HAVING country = 'Japan';
이렇게 하는거 보다
SELECT
country, city,
COUNT(id) AS country_user_count
FROM `thelook_ecommerce.users`
WHERE country = 'Japan'
GROUP BY country, city
원천적인 데이터로 구할 수 있는 건 왠만하면 WHERE
로 써주는게 좋아보임
오름차순
SELECT *
FROM `thelook_ecommerce.users`
ORDER BY id #ASC 를 붙여도됨
내림차순
SELECT *
FROM `thelook_ecommerce.users`
ORDER BY id DESC
여러개
SELECT *
FROM `thelook_ecommerce.users`
ORDER BY country, created_at DESC
국가별로 가입자수를 조회하는데 가입자 수가 많은 국가 2개만 추려
SELECT
country,
COUNT(id) AS USER_COUNT
FROM `thelook_ecommerce.users`
GROUP BY country
ORDER BY USER_COUNT DESC
LIMIT 2