Query editor
with prices_primary AS (SELECTDATE_TRUNC('day', timestamp) AS day,price_usd,token_addressFROM ton.prices_dailyWHERE token_address = '0:0000000000000000000000000000000000000000000000000000000000000000'),prices_fallback AS (SELECTday,AVG(price) / 1e9 AS price_usdFROM prices.usd_dailyWHERE symbol = 'TON'AND blockchain IS NULLGROUP BY 1),prices_combined AS (SELECTCOALESCE(p1.day, p2.day) AS day,COALESCE(p1.price_usd, p2.price_usd) AS price_usdFROM prices_primary p1FULL OUTER JOIN prices_fallback p2ON p1.day = p2.day)select year(block_date) as year,case when collection_address = '0:80D78A35F955A14B679FAA887FF4CD5BFC0F43B4A4EEA2A7E6927F3701B273C2'then 'Usernames'else 'Numbers'end as source,round(sum(sale_price * PC.price_usd)) as "Revenue, USD"from ton.nft_eventsLEFT JOIN prices_combined PCON block_date = PC.daywhere(collection_address = '0:80D78A35F955A14B679FAA887FF4CD5BFC0F43B4A4EEA2A7E6927F3701B273C2'orcollection_address = '0:0E41DC1DC3C9067ED24248580E12B3359818D83DEE0304FABCF80845EAFAFDB2')and type= 'sale' and prev_owner is nullgroup by 1, 2