解答

197

SQL文(クエリ)

WITH master AS (
  SELECT
    CONCAT(cid, session_count) AS session_id
    , MAX(IF(page = "/special/diet/", 1, 0)) AS view_diet_page
    , MAX(IF(page = "/thank_you/", 1, 0)) AS cv
  FROM
    sample.web_log
  GROUP BY
    session_id
)
SELECT
  view_diet_page_session
  , sum_cv / session AS cvr
FROM
  (
    SELECT
      IF(view_diet_page = 1, true, false) AS view_diet_page_session
      , COUNT(DISTINCT session_id) AS session
      , SUM(cv) AS sum_cv
    FROM
      master
    GROUP BY
      view_diet_page_session
  )

結果テーブル

結果テーブル

サポートページに戻る