FastPrepMost Popular Active Plan for the Top Event Type
Problems/Most Popular Active Plan for the Top Event Type

Most Popular Active Plan for the Top Event Type

Notion logoNotion● HardFULLTIMEPHONE SCREEN
QuestionConstraints

Problem statement

Source note: A Notion data-engineering phone-screen report asks, as a follow-up to the top-event-type query, which plan type is most popular for that event type and confirms joining event time against subscription start and end times. The executable columns and deterministic tie rules are authored assumptions.

First find the event type with the most event rows. Break an event-type tie alphabetically.

For events of that type, join the subscription active at each event time and return the plan with the most matching events. A subscription is active when start_time <= event_time < end_time; a null end_time means it is still active. Break a plan tie alphabetically. Return plan_type and event_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.

events

ColumnTypeNullableDescription
event_idPKIntegerNo—
user_idIntegerNo—
event_typeTextNo—
event_timeTimestampNo—

subscriptions

ColumnTypeNullableDescription
subscription_idPKIntegerNo—
user_idIntegerNo—
plan_typeTextNo—
start_timeTimestampNo—
end_timeTimestampYes—

Expected result

Your query or function must return these columns.

ColumnTypeNullableDescription
plan_typeTextNo—
event_countIntegerNo—

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

Constraints

  • At most one subscription is active for a user at any event time.
  • The selected top event type has at least one event with an active subscription.
  • The end boundary is exclusive.

More Notion problems

  • Nested Todo ListPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Top Error Types in a Time WindowONSITE INTERVIEW · Seen Jun 2026
  • DAG Downstream NodesONSITE INTERVIEW · Seen Apr 2026
All Notion interview questionsSee Notion hiring insights