Quick answer: Good SQL projects for students include a library system, student results database, e-commerce sales analysis, bank transactions, hospital appointments, food delivery analytics and HR attrition analysis. For each one, design four to six related tables, load realistic data and write 10 to 15 queries that answer business questions using joins, GROUP BY, CTEs and window functions.
Watching SQL tutorials teaches you syntax. SQL projects teach you to think like an analyst: design tables, load data and answer questions nobody has written the query for. They are also what interviewers ask about when they see "SQL" on your resume.
Below are twelve SQL project ideas, ordered from beginner to advanced. Each has a schema idea, the key queries to write and, for several, a sample query you can run in MySQL 8 or PostgreSQL. Pick one from each level and finish it properly rather than starting all twelve.
How to build any SQL project
Follow the same five steps for every project:
- Design the schema. Draw the tables, primary keys and foreign keys first. Our guide to database normalisation helps you avoid repeated data.
- Create the tables with proper data types and constraints. See CREATE TABLE in SQL if you need a refresher.
- Load realistic data: a few thousand rows, generated with Python's Faker library or taken from a public dataset.
- Write the business questions first, then the queries. A query without a question is just practice.
- Publish it on GitHub with a README listing questions and findings.
Beginner SQL mini projects
1. Library management system
Schema idea: books (book_id, title, author, category), members (member_id, member_name, joined_on), loans (loan_id, book_id, member_id, loan_date, due_date, return_date).
Key queries to write:
- Books currently on loan, and who has them.
- Overdue books with days overdue and a fine.
- The most borrowed categories each month.
- Members who have never borrowed a book.
-- Overdue books with a fine of Rs 5 per day (MySQL)
SELECT m.member_name,
b.title,
l.due_date,
DATEDIFF(CURRENT_DATE, l.due_date) AS days_overdue,
DATEDIFF(CURRENT_DATE, l.due_date) * 5 AS fine_rupees
FROM loans l
JOIN members m ON m.member_id = l.member_id
JOIN books b ON b.book_id = l.book_id
WHERE l.return_date IS NULL
AND l.due_date < CURRENT_DATE
ORDER BY days_overdue DESC;
Notice that return_date IS NULL marks books not yet returned. In PostgreSQL, replace DATEDIFF(CURRENT_DATE, l.due_date) with CURRENT_DATE - l.due_date, which returns the number of days directly.
2. Student results database
Schema idea: students (student_id, name, department, year), subjects (subject_id, subject_name, credits), marks (student_id, subject_id, semester, marks).
Key queries to write:
- Each student's average marks per semester.
- Subjects with the highest failure rate (marks below 40).
- Top three students in each department.
- Students who failed any subject in the latest semester.
-- Top 3 students per department by average marks
WITH avg_marks AS (
SELECT s.student_id, s.name, s.department,
AVG(mk.marks) AS avg_score
FROM students s
JOIN marks mk ON mk.student_id = s.student_id
GROUP BY s.student_id, s.name, s.department
)
SELECT department, name, ROUND(avg_score, 2) AS avg_score, dept_rank
FROM (
SELECT department, name, avg_score,
DENSE_RANK() OVER (PARTITION BY department
ORDER BY avg_score DESC) AS dept_rank
FROM avg_marks
) ranked
WHERE dept_rank <= 3
ORDER BY department, dept_rank;
DENSE_RANK gives tied students the same rank without skipping numbers, so you may get more than three rows for a department if there is a tie. That is usually the right behaviour for a rank list.
3. Personal expense tracker
Schema idea: categories (category_id, name), expenses (expense_id, category_id, amount, spent_on, payment_mode).
Key queries to write: monthly spend by category, the category that grew the most month on month, average daily spend, and spending split by UPI, card and cash. It is small, but it is a great first project because you understand the data personally.
4. Movie or music catalogue
Schema idea: movies, actors, movie_actors (a many-to-many link table), ratings (user_id, movie_id, rating, rated_on).
Key queries to write: top-rated movies with at least 50 ratings, actors who appeared together most often (a self join on movie_actors), average rating by genre and year. This project teaches many-to-many relationships, a common interview topic.
Intermediate SQL project ideas
5. E-commerce sales analysis
Schema idea: customers, products, orders (order_id, customer_id, order_date, status), order_items (order_id, product_id, quantity, unit_price).
Key queries to write:
- Monthly revenue and month-over-month growth.
- Top products by revenue in each category.
- Repeat customer rate.
- Average order value by city.
- Customers with no orders in the last 90 days.
-- Repeat customer rate: share of customers with 2+ delivered orders
WITH customer_orders AS (
SELECT customer_id, COUNT(*) AS order_count
FROM orders
WHERE status = 'DELIVERED'
GROUP BY customer_id
)
SELECT COUNT(*) AS customers_with_orders,
SUM(CASE WHEN order_count >= 2 THEN 1 ELSE 0 END) AS repeat_customers,
ROUND(100.0 * SUM(CASE WHEN order_count >= 2 THEN 1 ELSE 0 END)
/ COUNT(*), 1) AS repeat_rate_pct
FROM customer_orders;
Notice the 100.0 rather than 100. In PostgreSQL, dividing two integers gives an integer, so 100 * 3 / 7 would lose the decimals. MySQL returns a decimal either way, but writing 100.0 keeps the query correct in both.
6. Bank transactions system
Schema idea: customers, accounts (account_id, customer_id, account_type, opened_on), transactions (txn_id, account_id, txn_type, amount, txn_time).
Key queries to write:
- Running balance for each account.
- Accounts with no transactions in six months (dormant accounts).
- Days with unusually high withdrawals.
- Total credits and debits per customer per month.
-- Running balance per account
SELECT account_id,
txn_time,
txn_type,
amount,
SUM(CASE WHEN txn_type = 'CREDIT' THEN amount ELSE -amount END)
OVER (PARTITION BY account_id
ORDER BY txn_time, txn_id
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
AS running_balance
FROM transactions
ORDER BY account_id, txn_time, txn_id;
The window SUM adds credits and subtracts debits in time order. Adding txn_id to the ORDER BY breaks ties when two transactions share a timestamp, and the explicit ROWS frame stops tied rows being summed together.
7. Hospital appointment system
Schema idea: patients, doctors (doctor_id, name, specialisation), appointments (appointment_id, patient_id, doctor_id, slot_time, status).
Key queries to write: busiest doctors each month, no-show rate by specialisation, peak booking hours, patients with more than three visits in a quarter, and average gap between booking and appointment.
8. Food delivery analytics
Schema idea: restaurants, customers, delivery_partners, orders (order_id, restaurant_id, customer_id, partner_id, placed_at, delivered_at, amount, area).
Key queries to write: average delivery time by area and hour, restaurants with the most late deliveries (over 45 minutes), revenue by cuisine, and partners with the highest completed orders per day. Delivery time calculations teach you date arithmetic, which differs between databases, so check our MySQL vs PostgreSQL comparison.
Advanced SQL final year projects
9. HR and employee attrition analysis
Schema idea: employees (employee_id, name, department_id, manager_id, hire_date, exit_date, salary), departments, performance_reviews.
Key queries to write: attrition rate by department and year, average tenure of employees who left, salary bands with the highest exits, and the reporting chain for any employee using a recursive CTE on manager_id. The self-referencing manager_id column is also excellent practice for self joins.
10. Customer retention cohort analysis
Schema idea: reuse the e-commerce tables from project 5.
Key queries to write: group customers by the month of their first order (their cohort), then count how many from each cohort ordered again in months 1, 2 and 3 after joining. This needs CTEs, window functions such as MIN() OVER and date arithmetic. It is a real analyst task and an impressive final year project when paired with a heatmap in Power BI.
11. Inventory and supply chain system
Schema idea: products, warehouses, stock (product_id, warehouse_id, quantity), purchase_orders, sales.
Key queries to write: products below their reorder level, stock value per warehouse, slow-moving items with no sales in 60 days, and a supplier delivery delay report. Add a stored procedure that records a sale and reduces stock inside a transaction, so the two always stay in sync.
12. Ride-sharing analytics
Schema idea: riders, drivers, trips (trip_id, rider_id, driver_id, requested_at, started_at, ended_at, fare, pickup_zone, drop_zone, status), ratings.
Key queries to write: cancellation rate by zone and hour, driver earnings per week, the busiest pickup-to-drop routes, surge-hour detection using LAG to compare demand with the previous hour, and each driver's rank within their city using RANK().
Pro tip: For final year projects, add a front end. Connect your database to Power BI for a dashboard, or build a small Python or web app on top. The SQL stays the core, but examiners and interviewers can see your work, not just read it.
How to make your SQL projects stand out
- Write questions a manager would ask, not "select all rows from table".
- Use realistic data volume: thousands of rows, not ten.
- Add indexes on columns you filter and join on, and note the difference in your README.
- Include messy data (duplicates, nulls, inconsistent spellings) and show how you cleaned it.
- Document findings: a line such as "repeat customers are a minority of buyers but bring in most of the revenue" impresses far more than a list of queries, as long as your data actually shows it.
Common mistake: Copying queries from a tutorial project without changing the questions. Interviewers ask "Why did you write it this way?" and can tell quickly if you did not. Before you publish, check your queries against our list of common SQL mistakes.
For how SQL projects fit into a full analyst portfolio, read portfolio for data analysts, and for the full learning sequence, see our data analyst roadmap. Students in our Data Analytics with AI course build a SQL Business Insights project on customer, employee and sales tables as part of six portfolio projects.
Frequently asked questions
Which database should I use for SQL projects?
MySQL or PostgreSQL. Both are free, widely used and asked about in interviews. MySQL is common in Indian companies and courses, while PostgreSQL has a few extra features. The SQL you learn transfers between them with small syntax changes.
Where can I get data for SQL projects?
You can download public datasets from sites such as Kaggle or government open data portals, or generate realistic fake data with a Python library like Faker. Generating your own data is often better, because you control the table design and can add realistic messiness.
How many SQL projects should I put on my resume?
Two or three strong projects are enough. One beginner-level project and one or two advanced ones that use CTEs and window functions show more than a long list of small exercises.
Are SQL projects good enough for final year projects?
A pure SQL project can work for a final year project if it has a solid schema, realistic data volume and meaningful analysis. Many students make it stronger by adding a dashboard in Power BI or a simple web or Python front end on top of the database.
How do I present a SQL project on GitHub?
Include the schema file, a script that loads sample data, a queries file with each business question written as a comment above its query, and a README that lists the questions, the key findings and an ER diagram.
Want feedback on your SQL projects? Book a free counselling session and a CodeBegun trainer will review your skills and suggest which projects to build next.
