SQL for E-commerce: Funnel Conversion and Cohort Retention
<p>Kaveri Hills Coffee, a Bengaluru coffee brand that sells online, has to split its festive-season marketing budget, and it is hearing three different stories: the Instagram agency's, the analytics dashboard's, and the founder's hunch. Ananya Rao, the growth analyst, decides to answer from the store's own database: where do September's visitors drop out, which traffic sources bring real paying orders, and which customers come back?</p><p>Across five lessons you build the answers with her, in the store's own database, in an SQL lab in your browser: month filters that respect timestamps, staff sessions and messy campaign tags cleaned with LOWER and COALESCE, a funnel that counts sessions rather than events, step conversion with LAG(), joins that don't fan out, real orders separated from cancelled, RTO and test orders, new versus returning customers, monthly cohorts with calendar month numbers, a retention grid that leaves the future empty, a 90-day repeat rate with ROW_NUMBER(), and a source scorecard with LEFT JOIN and COALESCE. Every lesson you write the query yourself first, then hand the same job to your AI (ChatGPT, Claude, Copilot or Gemini) and learn exactly where it goes wrong. In the capstone your AI writes the final analysis from one brief, and you prove every number before the budget is spent.</p>
Tools: SQL (MySQL), COUNT(DISTINCT) and CTEs, Timestamps and DATE_FORMAT, Window functions (LAG, ROW_NUMBER), Conditional aggregation, Funnel and cohort analysis, AI assistants for SQL