Sessionize Bing Search Events and Measure a Satisfied Click Funnel

Last updated: November 29, 2026

Quick Overview

From a raw event log of searches and clicks with dwell times, split each user's events into sessions separated by more than 30 minutes of inactivity, then report per day how many sessions had a search, a click after the first search, and a satisfied click with at least 30 seconds of dwell.

Microsoft
Data Manipulation (SQL/Python)
Data Scientist
Microsoft
November 29, 2026
Data Scientist
Onsite
Data Manipulation (SQL/Python)
Hard

0

0

0 solved


From a raw event log of searches and clicks with dwell times, split each user's events into sessions separated by more than 30 minutes of inactivity, then report per day how many sessions had a search, a click after the first search, and a satisfied click with at least 30 seconds of dwell.

An onsite SQL exercise in the style of Microsoft's search and ads data science teams, where sessionization and the satisfied click (SAT click) are standard building blocks for Bing quality metrics. The interviewer checks window function fluency (LAG plus a running SUM), and whether you respect event order inside the session when defining funnel steps.

What the Interviewer Expects
  • Detect session starts with LAG and a 30-minute gap rule
  • Assign session ids with a running SUM of the start flags
  • Compute the first search time per session with a window MIN
  • Count only clicks that happen after the first search
  • Aggregate to one row per session before aggregating per day
Key Topics to Cover
sessionization
window functions
funnels
LAG
search metrics
How to Approach This
  1. Clarify the schema and expected output format before writing queries.
  2. Use CTEs (WITH clauses) to break complex queries into readable steps.
  3. Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
  4. Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
  5. For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
  • How would you attribute a session that spans midnight?
  • How would you compute time to first satisfied click per session?
  • How would you run this on a petabyte-scale log in a distributed engine?
  • Why might a 30-minute gap be wrong for mobile users, and how would you choose it?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice SQL Problems
Sample Answer
Clarify the Data

events(user_id, event_time, event_type, dwell_seconds) where event_type is search or click, and dwell_seconds is filled for clicks (time on the landing page before returning). A session ends...

Approach

Four stages, each one window or one aggregation. First, LAG gives each event the previous event time for that user; a missing or over-30-minute gap marks a session start. Second, a running SUM of ...


Submit Your Answer
Markdown supported