FastPrepUsers Active in Both January and February

Users Active in Both January and February

Mygate logoMygate● EasyFULLTIMEPHONE SCREEN

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

MySQLPostgreSQLPandas

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.

ColumnTypeNullableDescription
event_idPKIntegerNo—
user_idIntegerNo—
activity_dateDateNo—

Expected result

Your query or function must return these columns.

ColumnTypeNullableDescription
user_idIntegerNo—

Row order: must match exactly. Numeric tolerance: 0.

Constraints

  • The table contains between 0 and 10^4 rows.
  • event_id is unique and between 1 and 10^9.
  • user_id is an integer between 1 and 10^9.
  • activity_date is a valid date between 2020-01-01 and 2030-12-31.

More Mygate problems

See Mygate hiring insights