The New Users Daily Count SQL problem asks you to report the number of users who logged in for the first time on each date within a specified date range. For each user, identify their earliest login date, then count how many users had their first login on each day (filtering to dates within the given range). This is a SQL aggregation problem combining window functions or GROUP BY with a date filter.
LinkedIn asks this to test the ability to compute "first occurrence per user" in SQL — a common analytics task in user acquisition reporting. It validates knowledge of MIN() aggregation or window functions for finding each user's first event, followed by counting and date filtering. The database interview pattern requires combining GROUP BY, MIN, and conditional filtering cleanly.
Subquery + GROUP BY. Subquery: find the minimum login date per user — SELECT user_id, MIN(login_date) AS first_login FROM Logins GROUP BY user_id. Then outer query: filter to dates within the range and count users per date: SELECT first_login AS login_date, COUNT(*) AS user_count FROM subquery WHERE first_login BETWEEN start AND end GROUP BY first_login ORDER BY login_date.
Logins table: user 1 → dates [2019-05-01, 2019-05-02], user 2 → [2019-06-21], user 3 → [2019-05-01]. First logins: user 1 → 2019-05-01, user 2 → 2019-06-21, user 3 → 2019-05-01. Within range [2019-05-01, 2019-06-30]: count per date → 2019-05-01: 2, 2019-06-21: 1.
"First occurrence per user" is a very common SQL pattern in product analytics. Know two approaches: (1) MIN() GROUP BY in a subquery, then filter and aggregate; (2) Window function ROW_NUMBER() OVER (PARTITION BY user_id ORDER BY date ASC) then filter WHERE row_num=1. Practice both — interviewers may ask you to rewrite one using the other. Date range filtering with BETWEEN is clean and readable; always double-check inclusive boundary semantics.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Article Views II | Medium | Solve | |
| Active Businesses | Medium | Solve | |
| Active Users | Medium | Solve | |
| Activity Participants | Medium | Solve | |
| All People Report to the Given Manager | Medium | Solve |