with delegate as (select sum(amount/pow(10,6)) as delegate
from osmosis.core.fact_staking
where TX_STATUS = 'SUCCEEDED'
and action = 'delegate'
and currency = 'uosmo'
),
undelegate as (select sum(amount/pow(10,6)) as undelegate
from osmosis.core.fact_staking
where TX_STATUS = 'SUCCEEDED'
and action = 'undelegate'
and currency = 'uosmo')
select sum(delegate - undelegate)
from delegate, undelegate