MrftiBuy/Sell
    Updated 2024-04-02
    with tbl AS (
    select
    date_trunc (hour, Block_timestamp) as "Date",
    'Buy' as "Buy/Sell",
    TX_HASH as "Transaction hash",
    trader as "Trader address",
    PLATFORM as "Platform",
    AMOUNT_Out_USD as "Trade volume (USD)"
    from
    crosschain.defi.ez_dex_swaps
    where
    token_in = lower('0x57e114b691db790c35207b2e685d4a43181e6061')
    and blockchain = 'ethereum'
    UNION ALL
    select
    date_trunc (hour, Block_timestamp) as "Date",
    'Sell' as "Buy/Sell",
    TX_HASH as "Transaction hash",
    trader as "Trader address",
    PLATFORM as "Platform",
    AMOUNT_In_USD as "Trade volume (USD)"
    from
    crosschain.defi.ez_dex_swaps
    where
    token_out = lower('0x57e114b691db790c35207b2e685d4a43181e6061')
    and blockchain = 'ethereum'
    )
    select "Date", "Buy/Sell", count (DISTINCT "Transaction hash") as "Total tx", sum ("Trade volume (USD)") as "Total volume(USD)"
    from tbl
    GROUP by 1,2

    QueryRunArchived: QueryRun has been archived