Query editor
WITH data AS (SELECT bridge_name, array_agg(DISTINCT bridge_version) AS bridge_versions, SUM(amount_usd) FILTER (WHERE deposit_block_time > NOW() - interval '1' month) AS past_month_volume, CAST(COUNT(DISTINCT sender) FILTER (WHERE deposit_block_time > NOW() - interval '1' month) AS double) AS past_month_users, SUM(amount_usd) AS volume, CAST((SUM(amount_usd) FILTER (WHERE deposit_block_time > NOW() - interval '1' month AND deposit_chain = 'ethereum'))/(SUM(amount_usd) FILTER (WHERE deposit_block_time > NOW() - interval '1' month)) AS double) AS past_month_volume_ethereum, CAST(COUNT(DISTINCT sender) FILTER (WHERE deposit_block_time > NOW() - interval '1' month AND deposit_chain = 'ethereum') AS double) AS past_month_users_ethereum, AVG(date_diff('second', deposit_block_time, withdrawal_block_time)) FILTER (WHERE deposit_block_time IS NOT NULL AND withdrawal_block_time IS NOT NULL) AS avg_settle_time, approx_percentile(date_diff('second', deposit_block_time, withdrawal_block_time), 0.5) FILTER (WHERE deposit_block_time IS NOT NULL AND withdrawal_block_time IS NOT NULL) median_settle_timeFROM bridges_evms.flowsWHERE bridge_name!='Allbridge'GROUP BY 1), one_month_back_sub AS (SELECT bridge_name, SUM(amount_usd) AS one_month_ago_volume, CAST(COUNT(DISTINCT sender) AS double) AS one_month_ago_usersFROM bridges_crosschain.flows qWHERE deposit_block_time >= NOW() - interval '2' monthAND deposit_block_time < NOW() - interval '1' monthAND bridge_name!='Agglayer'GROUP BY 1)SELECT bridge_name, bridge_versions, past_month_volume, past_month_volume/one_month_ago_volume AS past_month_volume_change, past_month_users, past_month_users/one_month_ago_users AS past_month_users_change, volume, past_month_volume_ethereum, past_month_users_ethereum, avg_settle_time, median_settle_timeFROM dataINNER JOIN one_month_back_sub ob USING (bridge_name)ORDER BY 3 DESC