AITeky Learn

AiTeky Original Interactive Learning & Practice Intermediate

Advanced SQL: windows, cohorts, streaks and audits

Moving averages, shares and quartiles with window functions, set operations, cohorts, funnels, recursive calendars, streaks, customer segments and data audits, on the grocery app's database.

Basic SQL answers "how many?" and "how much?". Real analyst work asks harder questions: "How does this week compare with the same week last month?", "Which customers did we have in July but lose by September?", "Who are our best 10%?", "Is this table even correct?". Those need window functions, set operations, cohorts, recursive queries and checks written as queries, which are the things asked in senior analyst interviews.

You need the SQL course first. We use the same grocery app database: 60 customers, 25 products, 544 orders from July to September 2026 and 1,523 order lines.

  • Learn lessons build one technique at a time, with exercises you can repeat.
  • Industry ready lessons use the database for a customer segmentation and a data audit, and end with the interview questions that go with them.

Locked. Sign up free

Learn

Understand each idea with everyday examples. No coding background needed.

  1. 01 35 min Free sample πŸ”’ AiTeky Pass Window functions in depth: moving averages, comparisons and shares Use frames for moving averages, LAG for comparisons with last week, a window over the whole table for percent of total, PARTITION BY for shares within a group, and NTILE for quartiles.
  2. 02 30 min πŸ”’ AiTeky Pass Set operations and conditional totals: who stayed, who left, who came back Compare groups of customers with INTERSECT, EXCEPT and UNION, turn rows into columns with CASE and FILTER, and know the difference between UNION and UNION ALL.
  3. 03 30 min πŸ”’ AiTeky Pass Dates, cohorts and funnels Work with dates using strftime, group customers into signup cohorts and see how many are active each month, build an order funnel, and measure delivery times with percentiles.
  4. 04 30 min πŸ”’ AiTeky Pass Calendars, gaps and streaks with recursive queries Build a list of every date with a recursive query, find days with no activity that a plain GROUP BY hides, and find the longest streak of consecutive days with the gaps-and-islands trick.

Industry ready

Real problems from real jobs, and the questions interviewers ask about them.

  1. 05 40 min πŸ”’ AiTeky Pass On the job: segment customers with RFM Score every customer on recency, frequency and money with NTILE, name the segments with CASE, see how revenue is spread across them, and produce the win-back list for the retention team.
  2. 06 40 min πŸ”’ AiTeky Pass On the job: audit a new data feed with SQL checks Load a new batch of orders, write SQL checks for duplicates, orphans, bad dates, unknown values and impossible amounts, collect them into one report, reconcile totals between tables, and speed a slow query with an index.

We use essential cookies to run the site. With your permission we also set one anonymous ID to count unique visitors, and analytics cookies to see which pages help learners. Cookie notice

Join AiTeky Learn. It's free.

Create a free account to track your progress, save items for later and get study suggestions.

Sign up free Log in