Event Type with the Most Events
Reported by candidates from Notion's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The mistake that sinks most first attempts at this Notion question is counting distinct users instead of rows. It was reported in March 2026, and it's a clean GROUP BY problem with a tie-break trap. The task: find the event type with the most rows in the events table and return event_type and event_count. Repeated events from the same user all count. If two types tie, the alphabetically smallest wins. It's short, but the details decide it. If you blank during the live OA, StealthCoder runs invisibly as a safety net while you work.
The problem
Given an event log, return the event type with the largest number of event rows. If several types tie, return the alphabetically smallest type. Return exactly event_type and event_count. Tables events: event_id PK (Integer), user_id (Integer), event_type (Text), event_time (Timestamp) Constraints At least one event is present. Count every event row, including repeated events from the same user.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The pattern is group, count, order, limit. Group events by event_type and use COUNT(*) to get event_count. Then ORDER BY event_count DESC, event_type ASC and LIMIT 1. The second sort key is the whole tie-break rule, so don't skip it. The common pitfall is COUNT(DISTINCT user_id), which the constraints explicitly rule out since repeated events from one user count. Another slip is returning extra columns or aliasing the count wrong, because the output must be exactly event_type and event_count. NULLs in event_type aren't mentioned, so a NULL group could sneak in. COUNT(*) counts every row regardless, so it matches the spec. You don't need window functions here, though RANK works if you prefer. If the syntax slips under pressure, StealthCoder can give you the query in real time during the live OA.
The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.
You can drill Event Type with the Most Events cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Notion's OA.
Notion reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Event Type with the Most Events FAQ
What's the trick in the Notion event type question?+
The trick is the tie-break. Sort by event_count descending, then event_type ascending, and take one row. Most people get the count right and forget the alphabetical rule, so a tie silently returns the wrong type.
Should I use COUNT(*) or COUNT(DISTINCT user_id)?+
Use COUNT(*). The problem says to count every event row, including repeats from the same user. Distinct users would undercount and fail the cases where one user fires many events of the same type.
Do I need a window function or subquery?+
No. GROUP BY with ORDER BY and LIMIT 1 is enough. You can use RANK or a HAVING with a subquery, but those add risk. With a tie-break on the sort, the simple version is correct and easy to verify.
What columns should the output have?+
Exactly two: event_type and event_count, in that order. Alias COUNT(*) AS event_count. Extra columns or a differently named count can fail an exact-match check even when the logic is right.
How do I prepare for this in 48 hours?+
Write the query from memory three times on a sample table. Then add a tie case by hand and confirm the alphabetical winner comes back. Also practice variants like top N or most distinct users, since the same shape shows up often.