HARDVerified Real Interview• Product Data Scientist

7-Day Active Users Growth

The Growth team at Meta wants to track monthly active users (MAU) who were also active in the previous calendar month.

Write a query to calculate the number of retained active users for each month. A retained user in month $M$ is defined as a user who performed at least one action in month $M$ AND performed at least one action in month $M-1$. Output the month (as an integer 1-12 or date formatted 'YYYY-MM') and the count of retained active users. Order by month ascending.

Tables:

  • user_actions (user_id INT, event_id VARCHAR, action_date TIMESTAMP)

Execution Sandbox:

Your query executes inside an isolated in-memory PostgreSQL engine (PGlite WebAssembly). You have full access to standard PostgreSQL aggregations, window functions, and CTEs.

Standard SQL (ANSI)|Ln 1, Col 1
⌘↵ Run Query
Ready to execute. Press Run (⌘+Enter)
Write your query and click “Run” or press ⌘+Enter to inspect output.