Updated 2022-05-10
    with t1 as (select
    date as dt1,
    sum(balance) as LunaCirculatingSupply,
    count(distinct address) as unique_address
    from terra.daily_balances
    where date >= CURRENT_DATE - interval '90 days'
    and currency = 'LUNA'
    and address_label_type is NULL
    group by 1
    order by 1),

    t2 as (SELECT
    date as dt2,
    sum(balance) as stakedLuna,
    count(distinct address) as unique_address
    from terra.daily_balances
    where date >= CURRENT_DATE - interval '90 days'
    and currency = 'LUNA'
    and balance_type='staked'
    and address_label_type is NULL
    group by 1
    order by 1)

    select t1.dt1 as dt,
    LunaCirculatingSupply,
    stakedLuna,
    stakedLuna/LunaCirculatingSupply*100 as Percent_staked
    from t1 inner join t2 on t1.dt1=t2.dt2
    Run a query to Download Data