Query editor
WITH swaps_data AS (SELECTCOUNT(ic.tx_id) AS total_swaps,SUM(CASE WHEN ic.block_time >= CURRENT_TIMESTAMP - INTERVAL '1' DAY THEN 1 ELSE 0 END) AS swaps_24h, -- 24-hour swapsic.tx_signer AS addressFROMsolana.instruction_calls AS icWHEREic.executing_account = 'MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr'AND from_utf8(ic.data) LIKE '{"ref"%'AND ic.block_time >= TIMESTAMP '2024-06-04 00:00'AND ic.tx_success = trueGROUP BYic.tx_signer),grand_total AS (SELECTSUM(total_swaps) AS grand_total_swaps,SUM(swaps_24h) AS grand_total_swaps_24h -- 24-hour grand total swapsFROMswaps_data)SELECTROW_NUMBER() OVER (ORDER BY sd.total_swaps DESC) AS rank,sd.address,sd.total_swaps,sd.swaps_24h, -- Include 24-hour swaps in the final outputgt.grand_total_swaps,gt.grand_total_swaps_24h, -- Include 24-hour grand total swapsROUND((sd.total_swaps * 100.0 / gt.grand_total_swaps), 2) AS percentage_of_total,ROUND((sd.swaps_24h * 100.0 / gt.grand_total_swaps_24h), 2) AS percentage_of_24h -- Percentage of 24-hour swapsFROMswaps_data sdCROSS JOINgrand_total gtORDER BYsd.total_swaps DESC;