SQL Projects for Data Analysts: 8 Ideas With a Worked Example
Quick answer
Eight SQL project ideas for aspiring data analysts, with one worked end to end in runnable SQL and a guide to presenting it on GitHub.
Good SQL projects for data analysts answer a business question with joins, aggregation, CTEs and window functions on a multi-table dataset. Strong choices include customer retention analysis, sales and returns analysis, a UPI-style transaction audit and a funnel analysis. Finish two or three, publish the queries with a short write-up, and be ready to explain every line.
Key takeaways
- A project is a question plus an answer. "Which customers came back, and when?" is a project. "Queries on a sales table" is an exercise.
- Cover four skills across your projects: multi-table joins, GROUP BY with HAVING, CTEs and window functions.
- You need no server to start. SQLite stores a whole database in one file and has supported window functions since version 3.25.0.
- Publish the schema, the queries, the result tables and a five-line conclusion. The conclusion is the part a quick reader is most likely to see.
On this page:
- Which SQL projects should a data analyst build?
- What makes a SQL project good enough for a portfolio?
- How do you set up a database for practice without a server?
- How does a complete project look? A worked retention example
- How should you present SQL projects on GitHub and your resume?
- How do you talk about a project in interviews, and what should you avoid?
- Frequently asked questions
Which SQL projects should a data analyst build?
Build projects that mirror questions a manager would ask, graded from single-table summaries to window-function analysis. The eight below cover the range, with Indian business settings so you can explain the context easily in an interview.
| # | Project | Level | Business question | SQL you will practise |
|---|---|---|---|---|
| 1 | Kirana store sales summary | Beginner | Which products and days bring the most revenue? | SELECT, WHERE, GROUP BY, ORDER BY |
| 2 | College placement records | Beginner | Which branches and skills see the most offers? | Joins, COUNT, CASE |
| 3 | Customer retention | Intermediate | How many customers return each month? | CTEs, date functions, COUNT DISTINCT |
| 4 | E-commerce returns analysis | Intermediate | Which categories and sellers drive returns? | Multi-table joins, HAVING, ratios |
| 5 | Food delivery funnel | Intermediate | Where do users drop between search, cart and payment? | Conditional aggregation, self joins |
| 6 | UPI-style transaction audit | Advanced | Which transactions look duplicated or unusual? | Window functions, LAG, ROW_NUMBER |
| 7 | Ride-hailing demand by hour | Advanced | When and where does demand exceed supply? | Time bucketing, running totals, RANK |
| 8 | Subscription churn and revenue | Advanced | What is monthly recurring revenue, and who churned? | Recursive or calendar CTEs, LEAD, cohort tables |
Pick one from each level. Three finished projects that climb in difficulty show progress better than eight at the same level. For ideas that add Excel, Python or BI on top, see these data analytics project ideas for a portfolio.
What makes a SQL project good enough for a portfolio?
Four things: a real question, more than one table, a result someone could act on, and queries another person can run. Miss any one and it reads as homework.
Checklist before you start
- Question: written in one sentence, with a decision attached. "Should we offer a second-order coupon?"
- Data: at least three related tables, such as customers, orders and products. Use a public dataset or generate one, and say which.
- Messiness: some nulls, duplicates or inconsistent text to clean. Real data is never tidy.
- Skills shown: joins, grouping, a CTE and at least one window function.
- Answer: three to five findings in plain language.
If you need to refresh the building blocks first, use creating SQL tables and SQL joins explained with examples. Cleaning patterns are in data cleaning techniques.
How do you set up a database for practice without a server?
Use SQLite to begin, and move to PostgreSQL or MySQL when you want to match a job description. All three are free.
SQLite needs no installation of a server. Its official About page describes it as a self-contained, serverless, zero-configuration SQL database engine in which a complete database is contained in a single disk file. That makes a project easy to share: commit the file or a setup script to GitHub and anyone can run it. Python ships with a sqlite3 module, and free graphical tools exist if you prefer clicking to typing.
One caution. Date functions differ between databases: SQLite uses strftime, PostgreSQL uses to_char or date_trunc, MySQL uses DATE_FORMAT. State in your README which database your queries target.
How does a complete project look? A worked retention example
Here is project 3 in miniature. The question: how many customers who ordered in a month had also ordered in an earlier month? The data is a tiny illustrative table so you can check every number by hand.
Step 1: create and load the table
CREATE TABLE orders (
order_id INTEGER PRIMARY KEY,
customer_id INTEGER NOT NULL,
order_date TEXT NOT NULL,
amount INTEGER NOT NULL
);
INSERT INTO orders VALUES
(1, 101, '2025-01-05', 400),
(2, 102, '2025-01-18', 250),
(3, 101, '2025-02-02', 300),
(4, 103, '2025-02-11', 900),
(5, 101, '2025-03-09', 350),
(6, 102, '2025-03-15', 200),
(7, 104, '2025-03-20', 500);Step 2: monthly active and repeat customers
WITH first_order AS (
SELECT customer_id, MIN(order_date) AS first_date
FROM orders
GROUP BY customer_id
)
SELECT strftime('%Y-%m', o.order_date) AS month,
COUNT(DISTINCT o.customer_id) AS active_customers,
COUNT(DISTINCT CASE
WHEN strftime('%Y-%m', f.first_date) < strftime('%Y-%m', o.order_date)
THEN o.customer_id END) AS repeat_customers
FROM orders o
JOIN first_order f ON f.customer_id = o.customer_id
GROUP BY month
ORDER BY month;Result:
| month | active_customers | repeat_customers |
|---|---|---|
| 2025-01 | 2 | 0 |
| 2025-02 | 2 | 1 |
| 2025-03 | 3 | 2 |
Check it by hand. In March, customers 101, 102 and 104 ordered. 101 and 102 first ordered in January, so they are repeat customers; 104 is new. The CTE finds each customer's first order date once, and the main query compares it with each order's month.
Step 3: add a window function
The PostgreSQL documentation defines a window function as one that performs a calculation across a set of rows related to the current row, without grouping those rows into a single output row. That is what you need for a running total per customer and the gap since the previous order:
SELECT customer_id,
order_date,
amount,
SUM(amount) OVER (PARTITION BY customer_id ORDER BY order_date) AS running_spend,
LAG(order_date) OVER (PARTITION BY customer_id ORDER BY order_date) AS previous_order
FROM orders
ORDER BY customer_id, order_date;For customer 101 this returns running spend of 400, 700 and 1050, and previous order dates of NULL, 2025-01-05 and 2025-02-02. These queries were run on SQLite. According to the SQLite window functions documentation, window function support was added in version 3.25.0, and the built-in set includes row_number, rank, dense_rank, lag and lead.
Step 4: write the finding
"Two of the three customers active in March were returning customers. Customer 101 orders about once a month; customer 103 placed one large order and has not returned." On a real dataset with thousands of rows, the same queries produce a retention table a marketing team can use. Go deeper with SQL window functions explained.
How should you present SQL projects on GitHub and your resume?
Make the result visible without running anything. Recruiters often skim a repository quickly.
Repository layout
retention-analysis/
README.md
schema.sql
load_data.sql
queries/
01_monthly_retention.sql
02_running_spend.sql
results/
monthly_retention.csvREADME in five parts
- The question and why it matters.
- The data: source, tables, row counts, an ER diagram if you can.
- Three to five findings, each with a number.
- How to run it, and which database it targets.
- What you would do next with more data.
On your resume, write one line per project in the form question, method, result. Our guide to a data analyst resume for freshers has before-and-after examples.
How do you talk about a project in interviews, and what should you avoid?
Explain the decision first, then the query. Interviewers want to know that you understand why the query exists.
A structure that works in two minutes: the question, the tables and their grain, the trickiest query and why you wrote it that way, one thing that went wrong, the finding. Expect follow-ups such as "what happens to your count if a customer has two orders on the same day?" Practise with these SQL interview questions and answers.
Mistakes that weaken a project
- Using
SELECT *everywhere, which hides whether you know the columns. - Joining without checking for duplicated rows. Count rows before and after every join.
- Copying a tutorial dataset and its exact queries. Change the question at least.
- No conclusion. Twenty queries with no finding is a worksheet.
- Screenshots of code instead of text files that can be run.
Next step: run the retention example above today, then repeat it on a public dataset with at least three tables. If you want mentor feedback on projects across SQL, Python and BI, look at the Certification Program in Data Analytics with AI and Gen AI from E&ICT Academy, IIT Roorkee, a 06 months programme.
Frequently asked questions
How many SQL projects do I need for a data analyst job?
Two or three well-finished projects are enough. Aim for one beginner, one intermediate and one that uses window functions. Depth matters more than count: each should have a clear question, runnable queries and written findings.
Which database should I use for SQL projects?
Start with SQLite because it needs no server and stores the database in a single file. Move to PostgreSQL or MySQL to match job descriptions. Core SQL is the same across them, though date and string functions differ.
Where can I get data for SQL projects?
Use public datasets from open data portals and dataset repositories, sample databases that ship with database tools, or data you generate yourself with a script. Prefer datasets with several related tables, and always name the source in your README.
Are SQL projects enough to get a data analyst job?
SQL projects prove a core skill, but most analyst roles also expect Excel and a BI tool, and often basic Python and statistics. Use SQL projects as the base of a portfolio and add at least one dashboard built on the same data.
What is the difference between a SQL exercise and a SQL project?
An exercise practises one concept on a given table. A project starts from a business question, uses several tables, involves cleaning and several linked queries, and ends with findings someone could act on.