Recurring February Event Types
Return each February 2025 event type having at least two rows, sorted by count descending and name ascending.
- Aggregation
- HAVING
- Date analysis
- Filtering
- Sorting
Exercise brief
Understand the request
Product telemetry analyst The February review needs recurring event types within an exact month boundary.
Return February event types whose filtered ingestion population contains at least two rows.
Return
- Return event_name, event_count in this exact left-to-right order.
Constraints
- Use a half-open February interval in WHERE.
- Use HAVING COUNT(*) >= 2; do not deduplicate business_event_id.
Data you will use
Review the relevant tables before deciding how to join, filter, or aggregate them.
events
event_row_idINTEGERevent_nameVARCHAR(50)occurred_atDATETIME
Hints, when you need them
Open one clue at a time so you still do the reasoning.
Hint 1
First establish the February row population; only then group and assess event frequency.
Hint 2
Use an inclusive lower timestamp and exclusive March boundary in WHERE, then apply the count threshold in HAVING.
Hint 3
SELECT event_name, COUNT(*) AS event_count FROM events WHERE /* half-open February interval */ GROUP BY event_name HAVING /* grouped row threshold */ ORDER BY event_count DESC, event_name;
Verified SQL answer
Attempt the problem first, then compare structure and reasoning—not just syntax.
Reveal solution and explanation
SELECT event_name, COUNT(*) AS event_count FROM events WHERE occurred_at >= '2025-02-01 00:00:00' AND occurred_at < '2025-03-01 00:00:00' GROUP BY event_name HAVING COUNT(*) >= 2 ORDER BY event_count DESC, event_name;Why this works
Correctness: WHERE establishes the February row population before GROUP BY, and HAVING keeps only event groups meeting the aggregate threshold. Edge case: a row at exactly 2025-03-01 00:00:00 must be excluded; using an inclusive upper boundary would incorrectly make checkout qualify. Portability: half-open timestamp predicates and standard HAVING semantics are supported across the live engines.
Success check
Every returned type has at least two in-bound rows.
Expected result
Use this output to verify values, aliases, ordering, and row count.
| event_name | event_count |
|---|---|
| page_view | 7 |
Learn the concepts behind this answer
Strengthen your understanding with these targeted learning topics:
Continue practicing
Build the next SQL skill
Finding Duplicates & Data Quality
Detect identity collisions, profile NULL-aware conflicts, and compare deterministic survivors with production-safe SQL.
Ranking & NTH Value
Solve deterministic ranking, top-N, distribution, positional-frame, and rolling-window problems.
SQL Joins
Practice reliable INNER, LEFT, FULL, CROSS, self, semi, anti, range, temporal, and many-to-many join patterns.
Open the interactive workspace and practice across SQL topics.