Moeteract3
    Updated 2023-02-01



    with txs as (select
    *
    from
    (select
    BLOCK_TIMESTAMP,
    TX_SENDER,
    row_number()over(partition by TX_SENDER order by BLOCK_TIMESTAMP) as row_n
    from terra.core.fact_transactions
    ) where row_n < 3 )

    , first_tx as (select
    TX_SENDER,
    BLOCK_TIMESTAMP as first_tx
    from txs where row_n = 1

    )

    ,scnd_tx as (select
    TX_SENDER,
    BLOCK_TIMESTAMP as scnd_tx
    from txs where row_n = 2
    )

    ,time_diff as (select
    t.TX_SENDER,
    first_tx,
    scnd_tx,
    DATEDIFF(day,first_tx, scnd_tx ) as time_dif
    from first_tx t join scnd_tx v on t.TX_SENDER = v.TX_SENDER
    )

    select
    CASE
    Run a query to Download Data