Query editor
WITH pairs AS (SELECT *FROM query_5027293 AS pool (pair, token_0, token_1, token_0_code, token_1_code, pair_code)),final_swap_events AS (SELECTer.event_type,er.pair,p.pair_code,p.token_0_code,p.token_1_code,er.token_0,er.token_1,er.closed_at,er.closed_at_hour,er.amount_0_in,er.amount_0_out,er.amount_1_in,er.amount_1_out,er.txHash,fp0.token_price AS token_0_price,fp1.token_price AS token_1_priceFROM query_5026857 er -- FXDAO POOLS Soroswap - Pools: Swap Raw EventsLEFT JOIN pairs pON er.pair = p.pairLEFT JOIN query_5031688 fp0 -- fxdao stellar-hourly-price-filled-with-latestON er.token_0 = fp0.contract_id AND er.closed_at_hour = fp0.closed_at_hourLEFT JOIN query_5031688 fp1 -- fxdao stellar-hourly-price-filled-with-latestON er.token_1 = fp1.contract_id AND er.closed_at_hour = fp1.closed_at_hour),pair_stats AS (SELECTpair,pair_code,token_0_code,token_1_code,SUM(COALESCE(amount_1_in, 0)) + SUM(COALESCE(amount_1_out, 0)) AS total_token_1_volume,COUNT(DISTINCT txHash) AS transaction_countFROM final_swap_eventsGROUP BY pair, pair_code, token_0_code, token_1_code)SELECTpair,pair_code,token_0_code,token_1_code,total_token_1_volume,transaction_countFROM pair_statsORDER BY total_token_1_volume DESC;