▸case-01 Write a PostgreSQL SQL query to calculate N-day retention (specifically Day 0, Day 1, Day 7, and Day 30) for users in an e-commerce platform using the `users` table (`user_id`, `created_at`) and `user_actions` table (`user_id`, `action_timestamp`). Many developers mistakenly join `user_actions` on `created_at` directly without establishing user cohort start dates or fail to handle users with no activity on later days. Ensure all users from the cohort denominator are preserved. | fail→fail | 28,597 | 31,895 | +12% | 1 | 1 | 0% | 5,078 | 5,293 | +4% | 0 | 0 | — |
▸case-02 Construct a Snowflake SQL query that generates a cohort retention matrix with cohort creation week in rows and retention periods (Week 0 through Week 4) in columns for standard product usage logs in `app_events`. Analysts often rely on dynamic PIVOT clauses that fail when new weeks are introduced or write simple GROUP BY queries that output long vertical rows instead of a horizontal grid. | pass→pass | 19,448 | 21,330 | +10% | 1 | 1 | 0% | 2,880 | 4,100 | +42% | 0 | 0 | — |
▸case-03 Build a SQL query to calculate 30-day retention for mobile app user cohorts created in the past 60 days from table `user_signups` and `event_logs`. A common mistake in retention analytics is including recent signups (e.g., users who joined 5 days ago) in the denominator for Day 30 retention, which artificially inflates calculated churn. | pass→pass | 18,121 | 21,578 | +19% | 1 | 1 | 0% | 2,640 | 3,839 | +45% | 0 | 0 | — |
▸case-04 Write a SQL query in BigQuery to compute 7-day rolling retention (unbounded retention) for a SaaS platform using `signups` and `activity_logs`. A common error is using exact day equality (`DATE_DIFF(activity_date, signup_date, DAY) = 7`), which ignores users who returned on Day 8 or later. | pass→fail | 16,607 | 16,130 | -3% | 1 | 1 | 0% | 2,343 | 2,597 | +11% | 0 | 0 | — |
▸case-05 Optimize a retention SQL query targeting a multi-billion row event log table `raw_clickstream` in PostgreSQL. Querying raw logs directly via self-joins causes memory overflows and query timeouts because users log hundreds of actions per day. | pass→fail | 26,148 | 28,999 | +11% | 1 | 1 | 0% | 4,041 | 5,196 | +29% | 0 | 0 | — |
▸case-06 Provide a SQL query pattern to calculate daily cohort retention for a global app stored in `global_user_events` where `event_timestamp` is stored in UTC but business reporting requires US Eastern Time (`America/New_York`). Converting dates after truncating causes boundary events at 11 PM ET to be assigned to the wrong day. | pass→pass | 18,463 | 18,104 | -2% | 1 | 1 | 0% | 2,830 | 3,128 | +11% | 0 | 0 | — |
▸case-07 Write a SQL query for PostgreSQL calculating the product stickiness ratio (DAU / MAU) over a 30-day window for table `active_sessions`. Beginners often average daily active user counts divided by total monthly signups instead of dividing single-day DAU by unique monthly active users over the rolling 30-day period. | pass→pass | 18,674 | 18,371 | -2% | 1 | 1 | 0% | 2,667 | 3,031 | +14% | 0 | 0 | — |
▸case-08 Construct a SQL query that assigns users to cohort start dates using `user_events` table when there is no dedicated `users` or `signups` table. Beginners often use `GROUP BY user_id` in a subquery or mix non-aggregated columns, leading to syntax errors or incorrect cohort dates when calculating retention. | pass→fail | 16,389 | 18,463 | +13% | 1 | 1 | 0% | 2,205 | 3,127 | +42% | 0 | 0 | — |
▸case-09 Create a BigQuery SQL query to calculate bracketed retention where activity within Days 1-7 is Week 1, Days 8-14 is Week 2, and Days 15-21 is Week 3. A common error is using integer division without handling day zero or using overlapping `BETWEEN` date boundaries that double-count users across week boundaries. | fail→fail | 20,921 | 22,683 | +8% | 1 | 1 | 0% | 3,598 | 4,239 | +18% | 0 | 0 | — |
▸case-10 Write a data validation SQL query to test an existing retention calculation pipeline output table `cohort_retention_summary` (`cohort_date`, `period_offset`, `retained_users`, `cohort_size`). The pipeline frequently produces corrupted reports where Day 0 retention is less than 100%. | fail→pass | 16,307 | 16,934 | +4% | 1 | 1 | 0% | 2,284 | 4,087 | +79% | 0 | 0 | — |
▸case-11 Write a SQL query to calculate monthly cohort retention for a SaaS recurring subscription model using `subscriptions` (`user_id`, `start_date`, `end_date`, `status`). Beginners attempt to count discrete login events from event logs rather than testing active subscription date ranges across billing cycles. | pass→pass | 16,301 | 22,868 | +40% | 1 | 1 | 0% | 3,388 | 3,957 | +17% | 0 | 0 | — |
▸case-12 Create a SQL query that calculates the cumulative cohort churn rate and period-over-period incremental churn rate from a retention matrix table `retention_metrics` containing `cohort_month`, `month_number`, and `retention_rate`. | pass→pass | 12,588 | 15,521 | +23% | 1 | 1 | 0% | 2,796 | 2,652 | -5% | 0 | 0 | — |
▸case-13 Construct a SQL query to measure user resurrection for an online community platform using `user_daily_activity`. A resurrected user is defined as an active user in month M who was completely inactive in month M-1 but had activity prior to M-1. Analysts often misclassify new signups as resurrected users. | pass→pass | 16,758 | 19,622 | +17% | 1 | 1 | 0% | 3,482 | 4,566 | +31% | 0 | 0 | — |
▸case-14 Write a SQL query in Snowflake that formats retention cohort data from `app_usage` specifically for consumption by BI dashboard tools like Tableau as a standardized long-format dataset (`cohort_group`, `period_name`, `cohort_size`, `retained_count`, `retention_pct`). | pass→pass | 20,442 | 20,937 | +2% | 1 | 1 | 0% | 3,021 | 3,629 | +20% | 0 | 0 | — |
▸case-15 Write a SQL query in PostgreSQL to calculate 7-day retention specifically for core interaction events (where `event_name = 'completed_checkout'`) after initial signup in `users` (`user_id`, `signup_date`). Beginners often count any pageview event in the numerator, inflating retention metrics beyond actual feature engagement. | pass→pass | 15,812 | 12,747 | -19% | 1 | 1 | 0% | 2,972 | 2,837 | -5% | 0 | 0 | — |
▸case-16 Write a SQL query to calculate Return Retention (percentage of cohort users active on Day N or any day after Day N) versus Classic N-Day Retention (active exactly on Day N) for mobile app `user_sessions`. | pass→pass | 22,817 | 29,149 | +28% | 1 | 1 | 0% | 3,715 | 6,784 | +83% | 0 | 0 | — |
▸case-17 Write a SQL query to compute 1-day, 7-day, and 30-day cohort retention broken down by signup platform (`ios`, `android`, `web`) from `user_profiles` and `activity_logs`. Analysts often forget to include platform in the grouping set, aggregating all platforms together and masking platform-specific drop-offs. | pass→pass | 11,710 | 17,001 | +45% | 1 | 1 | 0% | 2,549 | 2,916 | +14% | 0 | 0 | — |
▸case-18 Write a SQL query in BigQuery to calculate retention across 14-day bi-weekly periods for subscription services in `user_activity`. | fail→fail | 22,425 | 22,437 | +0% | 1 | 1 | 0% | 3,866 | 4,045 | +5% | 0 | 0 | — |
▸case-19 Write a SQL query that generates cohort retention metrics ensuring cohorts with zero active users in subsequent periods still appear with 0 retained users and 0.0 retention percentage rather than missing rows. | pass→pass | 20,721 | 21,415 | +3% | 1 | 1 | 0% | 3,105 | 3,804 | +23% | 0 | 0 | — |
▸case-20 Build an XGBoost machine learning model pipeline in Python using `scikit-learn` and `xgboost` to predict individual customer Lifetime Value (LTV) and churn probability over the next 90 days based on historical transaction features. | pass→pass | 40,910 | 34,020 | -17% | 1 | 1 | 0% | 7,887 | 6,455 | -18% | 0 | 0 | — |
▸case-21 Write an Apache Airflow DAG in Python that orchestrates a daily ETL pipeline to extract raw clickstream events from AWS S3, clean the json records using PySpark, and load them into a PostgreSQL data warehouse. | pass→fail | 24,172 | 29,740 | +23% | 1 | 1 | 0% | 5,018 | 5,509 | +10% | 0 | 0 | — |
▸case-22 Design a real-time event streaming pipeline architecture using Apache Kafka and Redis pub/sub to track user click events in high-throughput web applications with sub-millisecond ingestion latency. | pass→fail | 37,022 | 35,557 | -4% | 1 | 1 | 0% | 6,724 | 6,043 | -10% | 0 | 0 | — |