解答

180

SQL文(クエリ)

SELECT
  register_age
  , COUNT(DISTINCT user_id) AS users
FROM
  (
    SELECT
      user_id
      , DATE_DIFF(register_date, birthday, YEAR) AS register_age
    FROM
      sample.customers
    WHERE
      birthday IS NOT NULL
    AND register_date IS NOT NULL
  )
GROUP BY
  register_age
ORDER BY
  2 DESC
LIMIT 3

結果テーブル

結果テーブル

サポートページに戻る