解答

169

SQL文(クエリ)

SELECT
  prefecture
  , ROUND(AVG(age), 1) AS avg_age
FROM
  (
    SELECT
      prefecture
      , DATE_DIFF("2019-12-31", birthday, YEAR) AS age
    FROM
      sample.customers
    WHERE
      birthday IS NOT NULL
  )
GROUP BY
  prefecture
ORDER BY
  2 DESC
LIMIT 3

結果テーブル

結果テーブル

サポートページに戻る