There is an ai_calls table that logs AI model usage. Every time a user calls a model, one row is appended, and each row holds the user who called it (user_id), the model used (model), the number of tokens spent (tokens), and the time of the call (created_at). Write a single SELECT statement that computes the monthly active users (MAU). Here an active user means a user who called a model that month. The result has two columns: - month : the month in 'YYYY-MM' form (e.g. '2026-05') - active_users : the number of active users who called a model that month Sort the result by month in ascending order. Write your query in solution.sql, and pressing 'Run test' runs it against a real database and shows the result table.
This challenge has you write a PostgreSQL SELECT statement for the monthly active users (MAU) from an AI model usage log. A log table that appends one row per call comes ready with data, and pressing 'Run test' runs your query against a real database and shows the result table. The result has two columns: one for the month, one for the number of users who used a model that month.
This problem is about "what are you actually counting when one row isn't one person." In log-like data where a single person leaves many rows, counting the rows to get the number of people counts rows, not people. Before trusting such an aggregate, don't just accept the number — feed a case where one person left several rows, run it for real, and watch with your own eyes how that person gets counted.