Query editor
WITH supply AS (SELECT date_trunc('month', time) AS month, contract_address, symbol, SUM(amount) AS total_amountFROM dune."21co".result_stablecoin_total_supply_on_ethereumGROUP BY 1, 2, 3),price AS (SELECTdate_trunc('month', minute) AS month,contract_address,symbol,AVG(price) AS priceFROM prices.usdWHERE minute >= date('2020-01-01')AND contract_address IN (SELECT DISTINCT contract_address FROM supply)AND blockchain = 'ethereum'GROUP BY 1, 2, 3UNION ALLSELECT month, contract_address, symbol, priceFROM dune."21co".result_stablecoin_missing_price),results AS (SELECTa.month AS time_month,a.symbol,total_amount * price AS market_capFROM supply aLEFT JOIN price bON a.month = b.monthAND a.contract_address = b.contract_address)SELECTtime_month,SUM(market_cap) AS total_market_capFROM resultsGROUP BY time_monthORDER BY time_month