解答

192

SQL文(クエリ)

WITH master AS (
  SELECT
    cid
    , session_count
    , COUNT(*) AS pv
    , MIN(date_time) AS s_start
    , MAX(date_time) AS s_end
  FROM
    sample.web_log
  GROUP BY
    cid
    , session_count
)
SELECT
  ROUND(SUM(session_duration) / COUNT(*), 1) AS avg_session_duration
FROM
  (
    SELECT
      cid
      , session_count
      , DATETIME_DIFF(s_end, s_start, second) AS session_duration
    FROM
      master
  )

結果テーブル

結果テーブル

サポートページに戻る