Users Active in Both January and February
Updated
Problem statement
The activity table records user activity events. Each row counts as one activity, and activity_date is a calendar date with no time or timezone conversion.
Find every user who has at least one activity in January 2025 and at least one activity in February 2025. Return one user_id row per qualifying user, sorted by user_id in ascending order.
Repeated events on the same date count as activity, but must not create duplicate result rows. Activity outside those two months, including the same months in another year, does not count.
Table schema
Use the same input data with any supported language. Open the Schema tab in the editor to see the generated SQL setup or Pandas DataFrames.
activity
One row per user activity event.
| Column | Type | Nullable | Description |
|---|---|---|---|
| event_idPK | Integer | No | — |
| user_id | Integer | No | — |
| activity_date | Date | No | — |
Expected result
Your query or function must return these columns.
| Column | Type | Nullable | Description |
|---|---|---|---|
| user_id | Integer | No | — |
Row order: must match exactly. Numeric tolerance: 0.
Constraints
- The table contains between 0 and 10^4 rows.
event_idis unique and between 1 and 10^9.user_idis an integer between 1 and 10^9.activity_dateis a valid date between2020-01-01and2030-12-31.
More Mygate Phone Screen questions
- Employees Earning More Than Their ManagerPHONE SCREEN · Seen Sep 2026
- Maximum Subarray SumPHONE SCREEN · Seen Sep 2026
- Reverse a Linked ListPHONE SCREEN · Seen Sep 2026
- Elements Occurring More Than n/3 TimesPHONE SCREEN · Seen Jan 2025
- Frog Jump: Minimum EnergyPHONE SCREEN · Seen Jan 2025
- Left View of a Binary TreePHONE SCREEN · Seen Jan 2025
- Two SumPHONE SCREEN · Seen Aug 2024
- Minimum in a Rotated Sorted ArrayPHONE SCREEN · Seen Jul 2024
- Minimum Subarray SumPHONE SCREEN · Seen Sep 2023
- Remove the Nth Node from the EndPHONE SCREEN · Seen Sep 2023
Similar questions at other companies
- Second Highest SalaryPaytm · PHONE SCREENPaytm interview questions
- Employees Who Earn More Than Their ManagersNykaa · PHONE SCREENNykaa interview questions
- Employees Who Joined More Than a Week AgoNewgen Software · PHONE SCREEN
- Departments Without EmployeesDell Technologies · PHONE SCREENDell Technologies interview questions
- Second-Highest Distinct SalaryChubb · PHONE SCREENChubb interview questions
- Swap Two Gender ValuesInfosys · PHONE SCREENInfosys interview questions
- Find Rows Common to Two TablesSalesforce · PHONE SCREENSalesforce interview questions
- Count Records Present in A but Not BCapital One · PHONE SCREENCapital One interview questions
- Customer Order Count Distribution by CountryApple · PHONE SCREENApple interview questions
- Classify Tree Nodes with SQLOracle · PHONE SCREENOracle interview questions