Query editor
WITH fees AS (-- Fees from sellsSELECT evt_block_time, t.feeFROM footballdotfun_base.fdfpair_evt_currencypurchaseCROSS JOIN UNNEST(transform(feeAmounts, x -> x / 1e6)) AS t(fee)WHERE evt_block_time >= NOW() - INTERVAL '24' hourUNION ALL-- Fees from buysSELECT evt_block_time, t.feeFROM footballdotfun_base.fdfpair_evt_playertokenspurchaseCROSS JOIN UNNEST(transform(feeAmounts, x -> x / 1e6)) AS t(fee)WHERE evt_block_time >= NOW() - INTERVAL '24' hour),volume AS (-- Volume from sells (currency received)SELECT evt_block_time, t.received_amount AS volumeFROM footballdotfun_base.fdfpair_evt_currencypurchaseCROSS JOIN UNNEST(transform(currencyReceived, x -> x / 1e6)) AS t(received_amount)WHERE evt_block_time >= NOW() - INTERVAL '24' hourUNION ALL-- Volume from buys (currency spent)SELECT evt_block_time, t.paid_amount AS volumeFROM footballdotfun_base.fdfpair_evt_playertokenspurchaseCROSS JOIN UNNEST(transform(currencySpent, x -> x / 1e6)) AS t(paid_amount)WHERE evt_block_time >= NOW() - INTERVAL '24' hour),fees_total AS (SELECT COALESCE(SUM(fee), 0) AS fees_last_24h FROM fees),vol_total AS (SELECT COALESCE(SUM(volume), 0) AS volume_last_24h FROM volume),tx_counts AS (SELECT COUNT(*) AS total_transactions_last_24hFROM (SELECT evt_block_timeFROM footballdotfun_base.fdfpair_evt_currencypurchaseWHERE evt_block_time >= NOW() - INTERVAL '24' hourUNION ALLSELECT evt_block_timeFROM footballdotfun_base.fdfpair_evt_playertokenspurchaseWHERE evt_block_time >= NOW() - INTERVAL '24' hour) t)SELECTROUND(fees_last_24h, 2) AS fees_last_24h,ROUND(volume_last_24h + fees_last_24h, 2) AS volume_plus_fees_last_24h,total_transactions_last_24hFROM fees_totalCROSS JOIN vol_totalCROSS JOIN tx_counts;