WITH
tab1 as (
SELECT
substring(memo, CHARINDEX('UNBOND:', memo) + 7, CHARINDEX('UNBOND:', memo) + 42) as operator,
count(distinct tx_id) as participations,
--cum(bonds) over (partition by operator order by days) as cum_bonds,
sum(e8/pow(10,8)) as rune_to_unbond
--sum(bonded) over (partition by operator order by days) as cum_rune_to_unbond
FROM thorchain.bond_events
WHERE bond_type = 'bond_returned' and memo like '%UNBOND:%' and CHARINDEX('UNBOND:', memo) > 0
group by 1
ORDER BY 1
)
SELECT
operator,
participations,
rune_to_unbond
from tab1
order by 2 desc