1. HAVING

최종적인 데이터에 필터를 더 걸어주는 함수

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 로 써주는게 좋아보임

ORDER BY

생각하는 순서

  1. SELECT
  2. FROM
  3. WHERE
  4. GROUP BY
    1. HAVING
  5. ORDERBY