MLDZMNFUR-Ethereum-1
    Updated 2022-12-20
    with tb5 as (select
    BLOCK_TIMESTAMP,
    from_address,tx_hash,
    ROW_NUMBER() OVER (partition by from_address order by BLOCK_TIMESTAMP) as t_n
    from ethereum.core.fact_transactions
    where STATUS='SUCCESS' and block_timestamp >= '2022-01-01'
    ),

    tb6 as (select
    BLOCK_TIMESTAMP as first_transaction,
    from_address
    from tb5
    where t_n=1),

    tb7 as (select
    BLOCK_TIMESTAMP as second_transaction,
    from_address
    from tb5
    where from_address in (select from_address from tb6)
    and t_n=2)
    ,

    tb8 as (select
    'Ethereum' as blockchain,
    tb6.from_address,
    avg(timediff('day',first_transaction, second_transaction )) as time_between
    from tb6
    join tb7 on tb6.from_address=tb7.from_address
    group by 1,2)

    select
    case
    when time_between<1 then 'a. Within 24 hours'
    when time_between>=1 and time_between<7 then 'c. 1 day to 1 week'
    when time_between>=7 and time_between<14 then 'd. 1 week to 2 weeks'
    when time_between>=14 and time_between<30 then 'e. 2 weeks to 1 month'
    Run a query to Download Data