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.
- βΆ Run code in your browser. Nothing to install
- β Exercises that check themselves
- π Tap a word to see what it means
Locked. Sign up free
Learn
Understand each idea with everyday examples. No coding background needed.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.

