with osmo_pools AS (
SELECT BLOCK_TIMESTAMP, POOL_IDS
FROM osmosis.core.fact_swaps
),
pools AS ( -- credit sam
select BLOCK_TIMESTAMP,
value as pool_id
from osmo_pools,
table(flatten(input => POOL_IDS)))
select 'pool '||pool_id as pool_name, count(*) as txs
from pools
where BLOCK_TIMESTAMP::date>='2022-05-01'
group by pool_id
order by txs --desc
limit 20