less than 1 minute read

Problem

problem-550

Query

WITH first_date_table AS (
    SELECT
        MIN(event_date) AS first_date, player_id
    FROM
        Activity
    GROUP BY
        player_id
)

SELECT 
    ROUND(
        (
            SELECT
                COUNT(*)
            FROM
                Activity AS a
            JOIN
                first_date_table AS f
                ON 
                    a.player_id = f.player_id AND a.event_date = DATE_ADD(f.first_date, INTERVAL 1 DAY)
        ) / count(DISTINCT player_id), 2
    ) AS fraction
FROM
    Activity

Tags:

Updated: