Sbhn_NPDistribution of Terra Wallets By Their Number of Active Days on Chain
    Updated 2023-02-02
    --credit : https://app.flipsidecrypto.com/velocity/queries/3d34bc4f-fe80-4aac-bce6-f19e202a9f30
    with maintable as (
    select tx_sender,
    count (distinct tx_id) as TX_Count,
    count (distinct block_timestamp::date) as Days_Count,
    sum (fee) as Total_Fee,
    avg (fee) as Average_Fee,
    median (fee) as Median_Fee,
    min (fee) as Minimum_Fee,
    max (fee) as Maximum_Fee
    from terra.core.fact_transactions
    where fee_denom = 'uluna'
    group by 1)

    select case when days_count = 1 then '1 Day'
    when days_count < 7 then 'Less Than 7 Days'
    when days_count >= 7 and days_count < 30 then '7 - 30 Days'
    when days_count >= 30 and days_count < 60 then '30 - 60 Days'
    when days_count >= 60 and days_count < 90 then '60 - 90 Days'
    when days_count >= 90 and days_count < 180 then '90 - 180 Days'
    when days_count >= 180 and days_count < 365 then '180 - 365 Days'
    else 'More Than 365 Days' end as type,
    count (distinct tx_sender)
    from maintable
    group by 1
    Run a query to Download Data