Skip to main content
SQL Practice·Compute DAU, WAU, MAU Metrics
Medium55% accepted

Compute DAU, WAU, MAU Metrics

Window FunctionsDATE_TRUNCAggregationUser Engagement
Problem Statement

Given a user_events table with user activity logs, compute Daily Active Users (DAU), Weekly Active Users (WAU), and Monthly Active Users (MAU) for each time period. Also compute the DAU/MAU ratio (stickiness) for each day.

Schema
CREATE TABLE user_events (
  id INTEGER PRIMARY KEY,
  user_id INTEGER NOT NULL,
  event_type TEXT NOT NULL,
  event_time TEXT NOT NULL
);
Complexity
TimeO(n log n)
Asked By
MetaAirbnbLyftSnap

Ready to solve?

Write and run your SQL query in the browser.