Handling Ties and Duplicate Timestamps
Concepts covered: sqlHaving
After the run_id is in place, the rest of the query is GROUP BY and aggregation. The interviewer at this level will probe whether you handle per-island thresholds and conditional aggregates correctly. The two most common probes: 'only return runs of at least N events' and 'compute statistics across the runs.' Each one tests where the threshold belongs in the query. 'Only return runs of at least N events' This is a per-island threshold. The filter applies to the aggregate (COUNT, SUM, MAX) after the GROUP BY, which means it belongs in a HAVING clause. WHERE filters individual rows before grouping; HAVING filters groups after the aggregate has been computed. HAVING COUNT(*) >= 5 filters out short sessions after the aggregate is computed. The query still computes the session_id correctly for
About This Interactive Section
This section is part of the Gaps and Islands: Intermediate lesson on DataDriven, a free data engineering interview prep platform. Each section includes explanations, worked examples, and hands-on code challenges that execute in real time. SQL queries run against a live database. Python runs in a sandboxed Docker container. Data modeling problems validate against interactive schema canvases. All content is framed around what data engineering interviewers actually test at companies like Meta, Google, Amazon, Netflix, Stripe, and Databricks.
How DataDriven Lessons Work
DataDriven combines four interview rounds (SQL, Python, Data Modeling, Pipeline Architecture) with adaptive difficulty and spaced repetition. Easy problems get harder as you improve. Weak concepts resurface until you master them. Your readiness score tracks progress across every topic interviewers test. Every lesson section ends with problems you solve by writing and running real code, not by picking multiple-choice answers.