Updated 2021-08-17
    with payments as
    (SELECT
    date_trunc('month', block_timestamp) as block_month,
    sum(event_amount)/2 as Transaction_KRT, event_currency,
    sum(event_amount_usd) Transaction_USD, count (DISTINCT tx_id) as Transactions_Count
    FROM terra.transfers
    WHERE (event_from_address_label = 'chai'
    OR event_to_address_label = 'chai') and tx_status = 'SUCCEEDED' and event_amount is not null and event_amount_usd is not null
    group by 1,3
    order by 1 desc
    limit 9),

    fees as
    (select sum(fee[0]:amount/1e6) as Fees_KRW, date_trunc('month', block_timestamp) as block_month
    from terra.transactions
    where tx_status != 'FAILED'
    and fee[0]:denom = 'ukrw'
    group by 2
    )

    select A.block_month, A.Transaction_KRT, A.Transactions_Count, B.Fees_KRW
    from payments A
    join fees B on A.block_month = B.block_month
    order by 1 desc
    Run a query to Download Data