nitsAverage Age Distribution
    Updated 2022-04-18
    with mints as
    (SELECT from_address as fa , max(block_timestamp) as last_mint from thorchain.swaps
    where contains(to_asset , '/')
    GROUP by 1 ),
    burns as
    (SELECT from_address , max(block_timestamp) as last_burn from thorchain.swaps
    where contains(from_asset , '/')
    GROUP by 1 )
    SELECT case
    when time_diff < 60 then 'a- less than a minute'
    when time_diff < 3600 then 'b- less than an hour'
    when time_diff < 60*60*8 then 'c- less than 8 hrs'
    when time_diff < 60*60*24 then 'd- less than a day'
    when time_diff < 60*60*24*7 then 'e- less than a week'
    else 'f- more than a week'
    end as distribution , count(DISTINCT from_address) as unique_users from
    (SELECT *, case when last_burn is NULL then -1 else abs(TIMESTAMPDIFF(SQL_TSI_SECOND, last_mint,last_burn)) end as time_diff
    from
    (SELECT * from mints
    left join burns on fa= from_address ))
    -- where last_burn is NULL
    -- LIMIT 100
    GROUP by 1
    Run a query to Download Data