解答

131

SQL文(クエリ)

WITH master AS (
  SELECT
    user_id
    , DATE_DIFF("2019-12-31", birthday, YEAR) AS age
  FROM
    sample.customers
  WHERE
    birthday IS NOT NULL
  AND gender = 1
)
SELECT
  age
  , COUNT(DISTINCT user_id) AS users
FROM
  master
GROUP BY
  age
ORDER BY
  2 DESC
LIMIT 3

結果テーブル

結果テーブル

サポートページに戻る