WITH t AS (
SELECT tx_id, COUNT(1) AS n
FROM thorchain.swaps
GROUP BY tx_id
having n=1
)
, swap_overtime_daily as (
select count(1) as swap_number,block_timestamp::date as swap_date from thorchain.swaps
where to_asset='THOR.RUNE' and tx_id in (select tx_id from t)
group by swap_date)
, swap_bychain as (
select count(1) as swap_number,blockchain from thorchain.swaps
where to_asset='THOR.RUNE' and tx_id in (select tx_id from t)
group by blockchain)
, swap_bnbchain_overtime as (select count(1) as swap_number,blockchain,block_timestamp::date as swap_date from thorchain.swaps
where to_asset='THOR.RUNE' and tx_id in (select tx_id from t)
group by blockchain,swap_date)
select * from swap_bychain