rezaramshiniUntitled Query
    Updated 2022-07-18
    with a as (
    select BLOCK_TIMESTAMP, payer, ROW_NUMBER() OVER (partition by payer order by BLOCK_TIMESTAMP) as number_of_tx from flow.core.fact_transactions
    where block_timestamp::date>CURRENT_DATE-35 )
    ,
    first_tx as (
    select BLOCK_TIMESTAMP as first_transaction, payer from a
    where number_of_tx=1)
    ,
    second_tx as (
    select BLOCK_TIMESTAMP as second_transaction,payer from a
    where number_of_tx=2)

    select first_tx.payer, DATEDIFF(day,first_transaction, second_transaction ) as Intervall
    from first_tx join second_tx on first_tx.payer=second_tx.payer
    -- group by 1
    Run a query to Download Data