WITH region_map AS (

  SELECT
    pref_code,
    CASE
      WHEN pref_code IN ('01', '02', '03', '04', '05', '06', '07') THEN '北海道・東北'
      WHEN pref_code IN ('08', '09', '10', '11', '12', '13', '14') THEN '関東'
      WHEN pref_code IN ('15', '16', '17', '18', '19', '20', '21', '22', '23', '24') THEN '中部'
      WHEN pref_code IN ('25', '26', '27', '28', '29', '30') THEN '近畿'
      WHEN pref_code IN ('31', '32', '33', '34', '35') THEN '中国'
      WHEN pref_code IN ('36', '37', '38', '39') THEN '四国'
      WHEN pref_code IN ('40', '41', '42', '43', '44', '45', '46', '47') THEN '九州・沖縄'
      ELSE NULL
    END AS region
  
  FROM 
        dataset.table
)

SELECT
  pref_code,
  region
FROM 
    region_map
WHERE
    region IS NOT NULL

都道府県コードの一覧:https://nlftp.mlit.go.jp/ksj/gml/codelist/PrefCd.html

おすすめの記事