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 page
Which 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 questionsA 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:
| Database | Engine | Licence line read | Good for |
|---|---|---|---|
| Chinook (github.com/lerocha/chinook-database) | SQLite, Postgres, MySQL, SQL Server and others | LICENSE.md is an MIT-style permission notice, copyright Luis Rocha 2008 to 2024 | Music store: artists, albums, tracks, invoices, customers |
| Northwind SQLite copy (jpwhite3/northwind-SQLite3) | SQLite | GitHub lists it as MIT | Orders, products, suppliers, employees |
| Pagila (devrimgunduz/pagila) | PostgreSQL | PostgreSQL Licence, copyright 2015 to 2026 | DVD rental: films, stores, rentals, payments |
| World Bank API | JSON over HTTP, load into any table | Datasets default to CC BY 4.0; some carry other licences and are labelled | Country indicators, India vs peers |
| Our World in Data energy-data repository | CSV | Creative Commons BY, credit the source | Wide 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.
| Idea | Level | Stack | Data source | Measure or ship |
|---|---|---|---|---|
| Which genres earn the most at a music store | Beginner | JOIN, GROUP BY | Chinook (MIT) | Top 5 genres by revenue and share of total |
| Employees by sales and tenure | Beginner | JOIN, date functions | Northwind (MIT) | Orders per employee per year |
| Customers who never bought | Beginner | LEFT JOIN, IS NULL | Chinook (MIT) | Count and share of customers with no invoice |
| Late shipments | Beginner | Date arithmetic, CASE | Northwind (MIT) | Late share by shipper |
| Rental inventory gaps | Beginner | JOIN, HAVING | Pagila | Films with more than 3 copies and zero rentals |
| India GDP rank among 10 peers | Beginner | Load JSON, RANK | World Bank API | Rank per year, 2000 to latest |
| Countries with the best electricity transition | Beginner | Filter, ORDER BY | Our World in Data energy | Top 10 by change in low-carbon share |
| Duplicate and orphan finder | Beginner | GROUP BY, anti-join | Any database above | Count of problems and a fix script |
| Customer spend quartiles | Intermediate | NTILE | Chinook (MIT) | Revenue share of the top quartile |
| Month-on-month revenue | Intermediate | CTE, LAG | Northwind (MIT) | Growth per month and the worst month |
| Top product per category | Intermediate | ROW_NUMBER | Northwind (MIT) | One row per category with revenue |
| Running total of rentals | Intermediate | SUM OVER | Pagila | Day the 10,000th rental happened |
| Supplier dependence | Intermediate | Subquery, share of total | Northwind (MIT) | Categories with one supplier over 50 percent |
| Basket analysis | Intermediate | Self-join | Chinook (MIT) | Top 10 track pairs bought together |
| Cohort retention in SQL | Intermediate | CTE, date truncation | Chinook invoices | Share of customers buying again within 90 days |
| Exchange-rate shock days | Intermediate | LAG, ABS | Frankfurter API loaded to a table | Days with a move over 1 percent |
| Query plan comparison | Intermediate | EXPLAIN QUERY PLAN, index | Any 100K row table | Time and plan before and after one index |
| Gaps and islands | Advanced | Window functions | Daily series from the starter | Longest streak of days above target |
| Recursive org chart | Advanced | Recursive CTE | Northwind employees | Reporting depth and span of control |
| Sessionisation | Advanced | LAG, SUM OVER | Synthetic click log | Sessions per user with a 30-minute gap rule |
| Slowly changing dimension | Advanced | UPSERT, validity dates | Your own mini dimension | Type 2 history table with 3 test cases |
| Data-quality test suite | Advanced | Assertions as queries | Any database above | 20 checks, pass or fail report |
| Rewrite 5 slow queries | Advanced | Indexes, rewrites | Pagila in Postgres | Milliseconds before and after, per query |
| Schema design from scratch | Advanced | DDL, constraints, normal forms | A clinic or library you invent | ER diagram, 5 tables, 3NF argument |
| SQL in a tiny web app | Advanced | Python, parameterised queries | Chinook | Search page and one injection test that fails safely |
How to choose by time and goal
| Time | Goal | Pick | Check you did it |
|---|---|---|---|
| One weekend | Prove joins and GROUP BY | Genres by revenue plus customers who never bought | Two queries, results match a manual count on 10 rows |
| One week | Analyst interviews | Month-on-month revenue, top product per category, cohort retention | Each uses a CTE or window function and is explained in the README |
| Two weeks | Stand apart | Query plan comparison and data-quality test suite | Timings reported with the machine and row count |
| Four weeks | Backend or data engineer roles | Schema design plus SCD2 plus a small app | Constraints, 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.
Learn this with mentors
Data and business analytics programmes with admissions open: live classes, mentors and project work.


