Meta’s Instagram Reels team tracks stickiness using the DAU/MAU ratio. Write a SQL query to compute this ratio for each of the past 30 days using Reels engagement activity.
For this question, define:
dau / mauUse the reels_events table below.
2024-06-30.activity_date, dau, mau, and dau_mau_ratio rounded to 4 decimal places.activity_date ascending.| column | type | description |
|---|---|---|
| event_id | INT | Primary key for each Reels event |
| user_id | INT | Meta user identifier |
| event_name | VARCHAR(50) | Reels action such as reels_play, ig_save, or reels_share |
| event_time | TIMESTAMP | Time of the event |
| surface | VARCHAR(50) | Product surface where the event happened |
| country_code | VARCHAR(2) | User country code |
| event_id | user_id | event_name | event_time | surface | country_code |
|---|---|---|---|---|---|
| 101 | 1001 | reels_play | 2024-06-30 09:10:00 | reels | US |
| 102 | 1002 | ig_save | 2024-06-30 11:00:00 | reels | IN |
| 103 | 1001 | reels_share | 2024-06-29 08:00:00 | reels | US |
| 104 | 1003 | reels_play | 2024-06-28 15:30:00 | reels | BR |
| 105 | 1004 | reels_play | 2024-06-15 12:00:00 | reels | US |
| 106 | 1005 | reels_play | 2024-06-01 10:00:00 | reels | GB |
| 107 | 1006 | reels_play | 2024-05-31 18:00:00 | reels | CA |
| 108 | 1002 | reels_play | 2024-05-20 09:00:00 | reels | IN |
| 109 | 1007 | reels_play | 2024-06-30 14:00:00 | fb_groups | US |
| 110 | 1008 | reels_play | NULL | reels | US |
| activity_date | dau | mau | dau_mau_ratio |
|---|---|---|---|
| 2024-06-28 | 1 | 6 | 0.1667 |
| 2024-06-29 | 1 | 6 | 0.1667 |
| 2024-06-30 | 2 | 6 | 0.3333 |