๐ŸŽ™ Free live masterclass ยท Sun, 29 Nov, 7:00 pm IST ยท Java Full Stack roadmap Register free โ†’
Skills101

Sales analysis with SQL

Load a real retail dataset and answer the questions a business analyst gets asked every week.

Intermediateโฑ 6โ€“10 hours๐Ÿชœ 7 stepsSQLPostgreSQL or SQLitePublic dataset

What you'll learn

  • โ—†Importing CSV data
  • โ—†CTEs and window functions
  • โ—†Turning questions into queries

What you'll build

  • โœ“Monthly revenue and growth %
  • โœ“Top products and customers
  • โœ“Repeat-customer rate
  • โœ“Cohort retention table

Step-by-step guide

  1. 1

    Get data

    Use a public dataset such as the "Superstore" sales CSV or the UCI Online Retail dataset.

  2. 2

    Load it

    CREATE TABLE matching the columns, then COPY (PostgreSQL) or .import (SQLite). Fix dates and nulls.

  3. 3

    Monthly revenue

    SELECT DATE_TRUNC('month', order_date), SUM(sales) ... GROUP BY 1; growth with LAG() OVER (ORDER BY month).

  4. 4

    Top N per group

    Top 3 products in each category with ROW_NUMBER() OVER (PARTITION BY category ORDER BY revenue DESC).

  5. 5

    Customers

    Repeat-customer rate = customers with 2+ orders / all customers, using a CTE.

  6. 6

    Cohorts

    First-purchase month per customer, then the share still buying 1, 2, 3 months later.

  7. 7

    Write it up

    A short report: 5 findings with the query and a chart for each (export results to Excel or use Python).

๐Ÿš€ Make it stand out

  • +Build a dashboard on top (Power BI or Metabase)
  • +RFM customer segments
  • +Discount impact analysis