CryptoIcicleFlow-13.Flow vs Other L1s - Flow - Week Later
    Updated 2022-07-16
    -- Payout 66.23 FLOW
    -- Grand Prize 198.68 FLOW
    -- Level Intermediate

    -- Q13. How does Flow compare to other L1s in terms of user retention? Is a user who made a transaction previously likely
    -- to make another transaction a week or a month later? Compare and contrast this type of activity vs other L1s like Solana and Ethereum

    with txns as (
    select
    payer as wallet,
    *
    from flow.core.fact_transactions
    where block_timestamp >= CURRENT_DATE - {{n_days}}
    ),
    txns2 as (
    select
    lag(block_timestamp, 1) ignore nulls over (partition by wallet order by block_timestamp asc) as previous_txn,
    datediff('day',previous_txn, block_timestamp) as previous_txn_n_days,
    *
    from txns
    qualify previous_txn is not null
    )

    (
    select
    block_timestamp::date as date,
    count(distinct wallet) as n_users_weekly,
    'week later' as type
    from txns2
    where previous_txn_n_days <= 7
    group by date
    )
    -- union
    -- (
    -- select
    -- block_timestamp::date as date,
    Run a query to Download Data