Query editor
-- ============================================================-- BITCOIN INCOME STATEMENT — TRADITIONAL FORMAT-- Parameter: {{period}} → enum: month, quarter, year-- Shows last 6 complete periods as columns-- ============================================================WITH base AS (SELECTdate_trunc('{{period}}', date) AS period,COUNT(*) AS block_count,SUM(transaction_count) AS tx_count,SUM(total_fees) AS fees_native,0.0 AS fee_burn_native,SUM(mint_reward) AS issuance_native,SUM(total_reward) AS miner_revenue_nativeFROM bitcoin.blocksGROUP BY 1),price AS (SELECTdate_trunc('{{period}}', minute) AS period,AVG(price) AS avg_price_usdFROM prices.usdWHERE blockchain IS NULLAND symbol = 'BTC'GROUP BY 1),metrics AS (SELECTb.period,b.tx_count,b.fees_native,b.fee_burn_native,b.issuance_native,b.miner_revenue_native,b.fees_native - b.issuance_native AS net_earnings_native,p.avg_price_usd,b.fees_native * p.avg_price_usd AS fees_usd,b.fee_burn_native * p.avg_price_usd AS fee_burn_usd,b.issuance_native * p.avg_price_usd AS issuance_usd,b.miner_revenue_native * p.avg_price_usd AS miner_revenue_usd,(b.fees_native - b.issuance_native)* p.avg_price_usd AS net_earnings_usdFROM base bLEFT JOIN price p ON b.period = p.period),numbered AS (SELECT m.*, ROW_NUMBER() OVER (ORDER BY period DESC) AS pnFROM metrics m),recent AS (SELECT * FROM numbered WHERE pn <= 6),line_items AS (