davidwallUntitled Query
    Updated 2023-01-19
    --credit : https://app.flipsidecrypto.com/velocity/queries/4d539c94-b5f2-46ff-9049-894294e4e2fd
    with lunapricet as (
    select date_trunc (hour,block_timestamp) as date1,
    median (to_amount/from_amount) as LUNA_Price
    from terra.core.ez_swaps
    where from_currency = 'uluna'
    and to_currency = 'ibc/B3504E092456BA618CC28AC671A71FB08C6CA0FD0BE7C8A5B5A3E2DD933CC9E4'
    and to_amount < 1e8 and from_amount < 1e8
    and block_timestamp >= '2023-01-01'
    group by 1 having LUNA_Price < 2 and LUNA_Price > 1.22 and LUNA_Price != 1.333487
    order by 1)

    select date_trunc(hour,block_timestamp) as date,
    case when block_timestamp::date = '2023-01-09' then '9 January'
    else 'Other Days' end as timespan,
    LUNA_Price,
    count (distinct tx_id) as TX_Count,
    count (distinct tx_sender) as Active_Users_Count,
    sum (fee) as Fees
    from terra.core.fact_transactions t1 join lunapricet t2 on date_trunc(hour,t1.block_timestamp) = t2.date1
    where block_timestamp::Date >= '2023-01-01'
    group by 1,2,3
    order by 1
    Run a query to Download Data