Updated 2021-08-18
    with total as
    (select
    date,
    max(balance) as total,
    balance_type,
    currency
    from terra.daily_balances
    where currency = 'LUNA' AND address != 'terra1fl48vsnmsdzcv85q5d2q4z5ajdha8yu3nln0mh'
    group by 1,3,4),

    totall as
    (select
    date, sum(total) as Total_LUNA
    from total
    group by 1),

    bluna as (
    select max(balance) as bonded, address_name, address, date
    from terra.daily_balances
    where address_name = 'bLuna Hub'
    group by 2,3,4
    order by 4 desc
    )

    select A.date, A.Total_LUNA, B.bonded, (A.Total_LUNA - B.bonded) as unbonded, B.bonded/unbonded as Ratio
    from totall A
    join bluna B on A.date = B.date
    order by 1 desc
    limit 30
    Run a query to Download Data