internalsGet Pro

Module 02 · Lesson 4 of 12Pro

Sessionization: grouping events into visits with SQL

Level
Intermediate
Topic
SQL for data engineering
Reading time
17 min

When you finish this page you can

  1. Group click events into visits with LAG and a running SUM, the gaps-and-islands method.
  2. Choose a visit timeout and a visitor id, and show how each choice changes visits and conversion per visit.
  3. Keep visit counts right when clicks arrive late, arrive twice or cross midnight, by rebuilding recent days.
  1. Design: a first analytics pipeline for an online store30 min
  2. Window functions: running totals and rankings17 min

Twelve clicks, four conversion rates

It’s Tuesday morning, 10 November, at . Kartly is an online store in India. Every night, Meera, its data engineer, loads the day’s orders and about 10 million click events from the store’s PostgreSQL database into DuckDB, where the reports read them.

Our biggest sale ever · Black Friday

Flat 50% Off

Pro

Continue reading

Unlock every course, now and later

  • System Design, live
  • AI Engineering, live
  • Data Engineering, live
  • Machine Learning Engineering, live
  • Inference Engineering, coming soon
  • AI Research, coming soon
  • Performance Engineering, coming soon
  • Agent & Harness Engineering, coming soon
  • LLM Fine-tuning, coming soon
  • LLM Pre-training & Post-training, coming soon
  • Reinforcement Learning, coming soon
  • AI Infrastructure & Platform Engineering, coming soon
  • AI Evaluation & Safety, coming soon
  • Forward Deployed Engineering, coming soon
  • Cloud Computing, coming soon
  • DevOps, coming soon

50% off · Annual and Lifetime

BLACKFRIDAY50Applied at checkout

Choose a plan