解答

189

SQL文(クエリ)

WITH master AS (
  SELECT
    user_id
    , SUM(revenue) AS sr
  FROM
    sample.sales
  GROUP BY
    user_id
)
SELECT
  gender_name
  , ROUND(STDDEV_POP(sr), 0) AS std_dev
FROM
  (
    SELECT
      CASE gender
        WHEN 1 THEN "男性"
        WHEN 2 THEN "女性"
        ELSE NULL
      END AS gender_name
      , sr
    FROM
      master
      LEFT JOIN sample.customers
      USING
        (user_id)
  )
GROUP BY
  gender_name

結果テーブル

結果テーブル

サポートページに戻る