Query editor
WITH weekly_metrics AS (SELECTDATE_TRUNC('{{Timeframe}}', block_time) AS week,factory,COUNT(DISTINCT token_address) AS tokens_created,COUNT(DISTINCT token_creator) AS unique_token_creatorsFROM dune.sealaunch_team.result_base_tokens_factoriesGROUP BY 1, 2),cumulative_metrics AS (SELECTweek,factory,tokens_created,unique_token_creators,SUM(tokens_created) OVER (PARTITION BY factoryORDER BY week) AS cumulative_tokens,SUM(unique_token_creators) OVER (PARTITION BY factoryORDER BY week) AS cumulative_token_creatorsFROM weekly_metrics)SELECTweek,factory,tokens_created AS weekly_tokens,cumulative_tokens,unique_token_creators,cumulative_token_creators,CAST(tokens_created AS DECIMAL(10,2)) / NULLIF(unique_token_creators, 0) AS tokens_per_creatorFROM cumulative_metricsWHERE week < (SELECT MAX(week) FROM cumulative_metrics)ORDER BY week DESC;