Query editor
WITH issuance_cte AS (SELECTdate_trunc('day', date) AS day,SUM(mint_reward) AS issuanceFROM bitcoin.blocksGROUP BY 1),circulation_cte AS (SELECTday,SUM(issuance) OVER (ORDER BY day ASC) AS circulatingFROM issuance_cteWHERE day >= DATE('2012-01-01')),last_output_cte AS (SELECTaddress,MAX(block_time) AS last_receivedFROM bitcoin.outputsGROUP BY 1),dormant_outputs AS (SELECTo.address,o.value / 1e8 AS btc_value,date_trunc('week', o.block_time) AS weekFROM bitcoin.outputs oLEFT JOIN bitcoin.inputs iON o.tx_id = i.spent_tx_idAND o.index = i.spent_output_numberJOIN last_output_cte lON o.address = l.addressWHEREi.spent_tx_id IS NULLAND l.last_received <= CURRENT_DATE - INTERVAL '10' YEAR),dormant_agg AS (SELECTweek,SUM(btc_value) AS dormant_10yFROM dormant_outputsGROUP BY 1),weekly_data AS (SELECTc.week,MAX(c.circulating) AS circulating,21000000 - MAX(c.circulating) AS not_mined,COALESCE(MAX(d.dormant_10y), 0) AS dormant_10yFROM (SELECTdate_trunc('week', day) AS week,circulatingFROM circulation_cte) cLEFT JOIN dormant_agg d ON c.week = d.weekGROUP BY c.week)SELECTweek,