1. Learn
  2. /
  3. Courses
  4. /
  5. SQL로 하는 탐색적 데이터 분석

Connected

Exercise

"other" 범주 만들기

Evanston 311 요청을 우편번호별로 요약하려면, 출현 빈도가 낮은 우편번호는 모두 "other" 범주로 묶어 두면 유용해요.

다음 쿼리에서 ???에 어떤 값을 넣어야 아래의 결과가 나올까요?

Query:

SELECT CASE WHEN zipcount < ??? THEN 'other'
       ELSE zip
       END AS zip_recoded,
       sum(zipcount) AS zipsum
  FROM (SELECT zip, count(*) AS zipcount
          FROM evanston311
         GROUP BY zip) AS fullcounts
 GROUP BY zip_recoded
 ORDER BY zipsum DESC;

Result:

zip_recoded    zipsum
60201          19054
60202          11165
null           5528
other          429
60208          255

Instructions

50 XP

Possible answers