Skip to content
Project ideas ยท Data Analytics

SQL projects for beginners: 25 ideas, free databases and a tested starter

Younus FardeenBy Younus FardeenUpdated 1 Dec 20268 min read
Short answer

A good SQL project answers one business question with joins, aggregates and window functions on a real sample database, then shows the queries, the result and one decision it supports. Start with Chinook or Northwind, both MIT-licensed, and write the README before you write the last query.

On this pageWhich free database to use, and its licence25 SQL project ideas by levelHow to choose by time and goal4-week plan and a runnable starterREADME and resume templateFrequently asked questions

A SQL portfolio is judged by three things: whether the queries are correct, whether you chose a question worth asking, and whether someone can rerun it. This page gives 25 ideas on free sample databases, a SQLite starter whose output is quoted from a real run, and a README that makes the project checkable.

We link to the joins and window-function explainers instead of repeating them: SQL joins explained and SQL window functions. Dataset licences were read on 1 December 2026.

Which free database to use, and its licence

Start with a sample database that has several related tables. A single flat CSV cannot teach joins. These were opened on 1 December 2026:

DatabaseEngineLicence line readGood for
Chinook (github.com/lerocha/chinook-database)SQLite, Postgres, MySQL, SQL Server and othersLICENSE.md is an MIT-style permission notice, copyright Luis Rocha 2008 to 2024Music store: artists, albums, tracks, invoices, customers
Northwind SQLite copy (jpwhite3/northwind-SQLite3)SQLiteGitHub lists it as MITOrders, products, suppliers, employees
Pagila (devrimgunduz/pagila)PostgreSQLPostgreSQL Licence, copyright 2015 to 2026DVD rental: films, stores, rentals, payments
World Bank APIJSON over HTTP, load into any tableDatasets default to CC BY 4.0; some carry other licences and are labelledCountry indicators, India vs peers
Our World in Data energy-data repositoryCSVCreative Commons BY, credit the sourceWide table to reshape into long format

SQLite itself is dedicated to the public domain, and Python ships a sqlite3 module, so you need no server. If a project needs Postgres features, run Pagila locally. Window functions need SQLite 3.25 or later; the starter below ran on SQLite 3.54.0. Do not scrape or republish a private company database, and keep any personal data out of a public repo.

25 SQL project ideas by level

Every row says what to measure, so your README ends with numbers. These deliberately avoid the e-commerce, churn and funnel ideas already in the data analytics project guide. Level means the hardest SQL feature you must use.

IdeaLevelStackData sourceMeasure or ship
Which genres earn the most at a music storeBeginnerJOIN, GROUP BYChinook (MIT)Top 5 genres by revenue and share of total
Employees by sales and tenureBeginnerJOIN, date functionsNorthwind (MIT)Orders per employee per year
Customers who never boughtBeginnerLEFT JOIN, IS NULLChinook (MIT)Count and share of customers with no invoice
Late shipmentsBeginnerDate arithmetic, CASENorthwind (MIT)Late share by shipper
Rental inventory gapsBeginnerJOIN, HAVINGPagilaFilms with more than 3 copies and zero rentals
India GDP rank among 10 peersBeginnerLoad JSON, RANKWorld Bank APIRank per year, 2000 to latest
Countries with the best electricity transitionBeginnerFilter, ORDER BYOur World in Data energyTop 10 by change in low-carbon share
Duplicate and orphan finderBeginnerGROUP BY, anti-joinAny database aboveCount of problems and a fix script
Customer spend quartilesIntermediateNTILEChinook (MIT)Revenue share of the top quartile
Month-on-month revenueIntermediateCTE, LAGNorthwind (MIT)Growth per month and the worst month
Top product per categoryIntermediateROW_NUMBERNorthwind (MIT)One row per category with revenue
Running total of rentalsIntermediateSUM OVERPagilaDay the 10,000th rental happened
Supplier dependenceIntermediateSubquery, share of totalNorthwind (MIT)Categories with one supplier over 50 percent
Basket analysisIntermediateSelf-joinChinook (MIT)Top 10 track pairs bought together
Cohort retention in SQLIntermediateCTE, date truncationChinook invoicesShare of customers buying again within 90 days
Exchange-rate shock daysIntermediateLAG, ABSFrankfurter API loaded to a tableDays with a move over 1 percent
Query plan comparisonIntermediateEXPLAIN QUERY PLAN, indexAny 100K row tableTime and plan before and after one index
Gaps and islandsAdvancedWindow functionsDaily series from the starterLongest streak of days above target
Recursive org chartAdvancedRecursive CTENorthwind employeesReporting depth and span of control
SessionisationAdvancedLAG, SUM OVERSynthetic click logSessions per user with a 30-minute gap rule
Slowly changing dimensionAdvancedUPSERT, validity datesYour own mini dimensionType 2 history table with 3 test cases
Data-quality test suiteAdvancedAssertions as queriesAny database above20 checks, pass or fail report
Rewrite 5 slow queriesAdvancedIndexes, rewritesPagila in PostgresMilliseconds before and after, per query
Schema design from scratchAdvancedDDL, constraints, normal formsA clinic or library you inventER diagram, 5 tables, 3NF argument
SQL in a tiny web appAdvancedPython, parameterised queriesChinookSearch page and one injection test that fails safely

How to choose by time and goal

TimeGoalPickCheck you did it
One weekendProve joins and GROUP BYGenres by revenue plus customers who never boughtTwo queries, results match a manual count on 10 rows
One weekAnalyst interviewsMonth-on-month revenue, top product per category, cohort retentionEach uses a CTE or window function and is explained in the README
Two weeksStand apartQuery plan comparison and data-quality test suiteTimings reported with the machine and row count
Four weeksBackend or data engineer rolesSchema design plus SCD2 plus a small appConstraints, tests and an ER diagram exist

Interview practice belongs next to projects: SQL interview questions and indexing explained cover the theory behind the plan comparison idea.

4-week plan and a runnable starter

Week 1: load a database, draw the table diagram, write 5 questions. Week 2: answer them with joins and aggregates, saving each query as its own file. Week 3: add window functions and one performance test. Week 4: write the README, add test queries and publish.

The starter builds a small shop database in SQLite, then runs a join, an anti-join, a CTE with LAG and a ROW_NUMBER query. The data is synthetic from a seeded generator, so the numbers will match yours.

import sqlite3, random

rng = random.Random(5)
con = sqlite3.connect(":memory:")
con.executescript('''
CREATE TABLE customers(id INTEGER PRIMARY KEY, name TEXT, city TEXT);
CREATE TABLE orders(id INTEGER PRIMARY KEY, customer_id INTEGER REFERENCES customers(id), order_date TEXT, amount REAL);
''')
cities = ["Pune", "Delhi", "Chennai", "Kolkata"]
con.executemany("INSERT INTO customers VALUES(?,?,?)",
                [(i, f"Customer {i}", cities[i % 4]) for i in range(1, 41)])
rows = []
for oid in range(1, 201):
    cid = rng.randint(1, 32)          # customers 33-40 never order
    month = rng.randint(1, 6)
    rows.append((oid, cid, f"2026-{month:02d}-{rng.randint(1,28):02d}", round(rng.uniform(200, 3000), 2)))
con.executemany("INSERT INTO orders VALUES(?,?,?,?)", rows)

def show(title, sql):
    print("--", title)
    for r in con.execute(sql):
        print("  ", r)

show("revenue by city (join + group by)", '''
SELECT c.city, COUNT(*) AS orders, ROUND(SUM(o.amount)) AS revenue
FROM orders o JOIN customers c ON c.id = o.customer_id
GROUP BY c.city ORDER BY revenue DESC''')
show("customers with no orders (anti-join)", '''
SELECT COUNT(*) FROM customers c LEFT JOIN orders o ON o.customer_id = c.id
WHERE o.id IS NULL''')
show("month-on-month revenue (CTE + window LAG)", '''
WITH m AS (SELECT substr(order_date,1,7) AS ym, SUM(amount) AS rev FROM orders GROUP BY ym)
SELECT ym, ROUND(rev) AS rev, ROUND(100.0*(rev - LAG(rev) OVER (ORDER BY ym)) / LAG(rev) OVER (ORDER BY ym), 1) AS mom_pct
FROM m ORDER BY ym''')
show("top customer per city (ROW_NUMBER)", '''
SELECT city, name, ROUND(total) FROM (
  SELECT c.city, c.name, SUM(o.amount) AS total,
         ROW_NUMBER() OVER (PARTITION BY c.city ORDER BY SUM(o.amount) DESC) AS rn
  FROM orders o JOIN customers c ON c.id = o.customer_id GROUP BY c.id)
WHERE rn = 1 ORDER BY city''')

Real output (Python 3.9.6, SQLite 3.54.0):

-- revenue by city (join + group by)
   ('Kolkata', 57, 84954.0)
   ('Delhi', 51, 77385.0)
   ('Pune', 51, 76986.0)
   ('Chennai', 41, 70870.0)
-- customers with no orders (anti-join)
   (8,)
-- month-on-month revenue (CTE + window LAG)
   ('2026-01', 64131.0, None)
   ('2026-02', 42830.0, -33.2)
   ('2026-03', 50329.0, 17.5)
   ('2026-04', 56517.0, 12.3)
   ('2026-05', 48262.0, -14.6)
   ('2026-06', 48125.0, -0.3)
-- top customer per city (ROW_NUMBER)
   ('Chennai', 'Customer 30', 11524.0)
   ('Delhi', 'Customer 9', 16407.0)
   ('Kolkata', 'Customer 11', 16999.0)
   ('Pune', 'Customer 24', 20054.0)

Customers 33 to 40 never order by design, and the anti-join finds exactly those 8. That is the pattern for every project: plant a known answer, then prove your query finds it.

README and resume template

  • README: Business question, Schema diagram, Data source and licence, How to run (one command), Queries (one file per question, each with the result), Findings, Limits, What I would do next.
  • Add a tests file: queries that must return zero rows, such as duplicate keys or orders without customers.
  • Resume bullet: "Wrote [n] SQL queries (joins, CTEs, window functions) on the Chinook database to find [finding]; cut one query from [x] ms to [y] ms with an index."
  • Name the SQL dialect (SQLite or PostgreSQL) so a reviewer knows what to run.

If you want charts on top of your queries, see Power BI projects and the Data Analytics learning path. For loading data automatically, try the data engineering projects.

Frequently asked questions

What SQL project should a beginner start with?

Start with a database that has related tables, such as Chinook, and answer three questions: revenue by genre, customers who never bought, and spend per customer. That covers joins, GROUP BY and a LEFT JOIN anti-join, the three patterns interviewers test first.

Which free database is best for SQL portfolio projects?

Chinook and the Northwind SQLite copy are both MIT-licensed on GitHub and run in SQLite with no server. Pagila suits PostgreSQL practice under the PostgreSQL Licence. Pick one, name it in the README and keep the licence file in your repo.

Do I need MySQL or PostgreSQL for a SQL project?

No. Python includes the sqlite3 module and SQLite supports joins, CTEs and window functions from version 3.25. Use PostgreSQL only if your project is about its features, and state the dialect in your README so reviewers can rerun the queries.

How many SQL queries should a portfolio project have?

Enough to answer 5 questions well, usually 10 to 20 queries including checks. Each should have a question, the SQL, the result and one sentence of meaning. A long list of unexplained queries is weaker than a short, tested one.

Can I put a SQL project on my resume without a job?

Yes, label it as a self-directed project on a public sample database. Give the dialect, the features used and one measured outcome, for example a query time before and after an index. Never claim business impact that did not happen.

How do I make a SQL project look different from everyone else's?

Add proof: a tests file that checks data quality, an EXPLAIN QUERY PLAN comparison, and a written assumption list. Choose a less common question, such as supplier dependence or gaps and islands, rather than the standard top-10 sales query.

Continue learning

Interview prep

SQL interview questions

40 questions, one practice schema, every result run on SQLite

11 min read
Concept

SQL window functions

Ranking, LAG, running totals and gaps and islands, with real SQLite output

7 min read
Concept

Indexing in databases

Query plans and timings on 200,000 rows, composite, covering, clustered

8 min read