建立「other」類別
如果你想按郵遞區號彙總 Evanston 的 311 服務請求,把所有出現頻率低的郵遞區號合併到一個「other」類別會很實用。
以下哪些數值代入查詢中的 ???,會得到底下的結果?
查詢:
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;
結果:
zip_recoded zipsum
60201 19054
60202 11165
null 5528
other 429
60208 255
本練習屬於課程
