Query editor
/* Success! If you're still running into issues, check out https://dune.com/docs/query/syntax-differences/ or reach out in the #dune-sql Discord channel. */SELECTregistered.month,registered.total_cost_eth AS "registration cost eth",registered.total_cost_usd_then AS "registration cost usd",renewed.total_cost_eth AS "renewal cost eth",renewed.total_cost_usd_then AS "renewed cost usd",registered.registered_count AS "registration count",registered.avg_eth_prc as "average eth price",renewed.renewed_count AS "renewal count",registered.count_temp_premium AS "registration temp premium count",registered.total_temp_premium_usd_then AS "registration temp premium usd"FROM(SELECTDATE_TRUNC('month', minute) AS "month",COUNT(cost) AS registered_count,AVG(eth_prc) as avg_eth_prc,SUM(cost) AS total_cost_eth,SUM(cost_usd_then) AS total_cost_usd_then,SUM(with_temp_premium) AS count_temp_premium,SUM(temp_premium) AS total_temp_premium_usd_thenFROM(SELECTr.minute,r.cost / POWER(10, 18) AS "cost",p.eth_prc,r.cost / POWER(10, 18) * p.eth_prc AS "cost_usd_then",r.cost / POWER(10, 18) * cp.price AS "cost_usd_now",CASEWHEN ROUND((r.cost / POWER(10, 18) * p.eth_prc)) - ROUND((EXTRACT(dayFROMFROM_UNIXTIME(cast(expires as double)) - evt_block_time) / 365 * base_price)) > (base_price / 10) THEN ROUND((r.cost / POWER(10, 18) * p.eth_prc)) - ROUND((EXTRACT(dayFROMFROM_UNIXTIME(cast(expires as double)) - evt_block_time) / 365 * base_price))ELSE 0END AS temp_premium,CASEWHEN ROUND((r.cost / POWER(10, 18) * p.eth_prc)) - ROUND((EXTRACT(dayFROMFROM_UNIXTIME(cast(expires as double)) - evt_block_time) / 365 * base_price)) > (base_price / 10) THEN 1