解答

193

SQL文(クエリ)

WITH s_users AS (
  SELECT
    user_id
  FROM
    sample.sales
  GROUP BY
    user_id
)
, w_users AS (
  SELECT
    user_id
  FROM
    sample.web_log
  GROUP BY
    user_id
)
SELECT
  COUNT(DISTINCT w_user) / COUNT(DISTINCT s_user) AS web_usage_rate
FROM
  (
    SELECT
      s_users.user_id AS s_user
      , w_users.user_id AS w_user
    FROM
      s_users
      LEFT JOIN w_users
      ON s_users.user_id = w_users.user_id
  )

結果テーブル

結果テーブル

サポートページに戻る