Query editor
WITH top_sandwiches AS (SELECT DISTINCT fr_tx, extracted_value_usdFROM query_5017013ORDER BY extracted_value_usd DESCLIMIT 30)SELECTdate_trunc('day', block_time) as date, MAX(extracted_value_sol) AS extracted_value_sol, MAX(sandwich_profit_or_loss_sol ) AS profit_sol, -MAX(sandwich_cost_sol) AS cost_sol, dex, token_pair, get_href('https://solscan.io/account/' || searcher, SUBSTRING(searcher, 1, 10) || '...')AS searcher, CASEWHEN possible_bot_program IN ('direct', 'JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4', 'routeUGWgWzqBWFcrCfv8tritsqukccJPu3q5GPP3xS') THEN 'Offchain'ELSE get_href('https://solscan.io/account/' || possible_bot_program, SUBSTRING(possible_bot_program, 1, 10) || '...')END AS associated_program, get_href('https://solscan.io/tx/' || fr_tx, SUBSTRING(fr_tx, 1, 10) || '...')AS fr_tx, ARRAY_AGG(vic_tx) AS victim_txs, get_href('https://solscan.io/tx/' || br_tx, SUBSTRING(br_tx, 1, 10) || '...')AS br_tx, approx_distinct(victim) as num_of_victims, SUM(victim_loss_sol) AS victim_loss_sol, SUM(victim_loss_usd) AS victim_loss_usd, MAX(extracted_value_usd) as extracted_value_usd, MAX(sandwich_profit_or_loss_usd) AS profit_usd, block_idFROMquery_5017013WHEREfr_tx IN (SELECT fr_tx FROM top_sandwiches)GROUP BY1, 5, 6, 7, 8, 9, 11, 17ORDER BYextracted_value_sol DESC