rajsCosmos # of Voters Over Time
    Updated 2023-01-12
    with voters as
    (
    SELECT
    voter,
    min(block_timestamp) as min_date
    from cosmos.core.fact_governance_votes
    where tx_succeeded
    group by 1
    )
    ,

    new_voters as
    (
    SELECT
    date_trunc('week', min_date) as date,
    count(voter) as no_of_new_voters
    from voters
    group by 1
    )
    ,

    active_voters as
    (
    SELECT
    date_trunc('week', block_timestamp) as date,
    count(distinct voter) as no_of_active_voters
    from cosmos.core.fact_governance_votes
    where tx_succeeded
    group by 1
    )

    SELECT
    a.*,
    no_of_new_voters,
    no_of_active_voters - no_of_new_voters as no_of_returning_voters,
    sum(no_of_new_voters) over (order by n.date) as cum_no_of_voters
    Run a query to Download Data