Tutorial

SQL Projects for All Levels: Beginner to Advanced Portfolio Guide

Stand out to hiring managers with these 6 real-world SQL projects for beginner, intermediate, and advanced data analysts with datasets and code.

Anuj SainiSep 8, 20264 min read

End-to-End SQL Project Walkthrough: E-Commerce RFM Customer Segmentation

To illustrate how senior analysts architect portfolio-grade sql projects, here is a complete production query pattern implementing RFM (Recency, Frequency, Monetary) segmentation on transactional data. Explore our complete SQL Tutorials hub for more scenario templates.

sql
-- Production RFM Customer Segmentation Model
WITH CustomerBase AS (
    SELECT 
        customer_id,
        -- Recency: Days since last order relative to fixed benchmark date
        DATE_PART('day', '2026-09-08'::timestamp - MAX(order_date)) AS recency_days,
        -- Frequency: Total count of completed orders
        COUNT(DISTINCT order_id) AS frequency_count,
        -- Monetary: Total gross spend
        SUM(order_amount) AS monetary_value
    FROM fact_orders
    WHERE order_status = 'Completed'
    GROUP BY customer_id
),
RFMScores AS (
    SELECT 
        customer_id,
        recency_days,
        frequency_count,
        monetary_value,
        -- Score 1 (worst) to 5 (best) using NTILE quartiles
        NTILE(5) OVER (ORDER BY recency_days DESC) AS r_score,
        NTILE(5) OVER (ORDER BY frequency_count ASC) AS f_score,
        NTILE(5) OVER (ORDER BY monetary_value ASC) AS m_score
    FROM CustomerBase
)
SELECT 
    customer_id,
    recency_days,
    frequency_count,
    monetary_value,
    (r_score || f_score || m_score) AS rfm_cell,
    CASE 
        WHEN r_score >= 4 AND f_score >= 4 AND m_score >= 4 THEN 'Champions'
        WHEN r_score >= 3 AND f_score >= 3 THEN 'Loyal Customers'
        WHEN r_score >= 4 AND f_score = 1 THEN 'Recent New Customers'
        WHEN r_score <= 2 AND f_score >= 3 THEN 'At Risk / Need Attention'
        WHEN r_score = 1 AND f_score = 1 THEN 'Lost Customers'
        ELSE 'Potential Loyalist'
    END AS customer_segment
FROM RFMScores
ORDER BY monetary_value DESC;

This single query showcases CTE modularity, date math, windowed quantiles (NTILE), conditional CASE statements, and business metric derivation—the exact skills hiring managers evaluate in take-home data challenges.

How to Present Your SQL Projects on GitHub and Resumes

Follow this checklist to maximize callback rates:

  1. Repository Structure:
    • /queries/: Organized .sql files named sequentially (01_schema_setup.sql, 02_kpi_analysis.sql).
    • /visuals/: Charts, ER diagrams, or dashboard screenshots.
    • README.md: Concise executive summary with business findings.
  2. Resume Bullet Point Formula: Weak: "Wrote SQL queries to analyze customer data." Strong: "Engineered an end-to-end SQL customer analytics pipeline analyzing 100k+ transactions across 9 tables; uncovered an 18% delivery delay bottleneck leading to actionable logistics recommendations."

To expand your portfolio beyond SQL, explore our guide on building an end-to-end data analytics portfolio and check our curated Topfolio projects catalog.


Summary Checklist for SQL Projects

  • Choose authentic, messy public datasets over overused toy datasets.
  • Incorporate CTEs, window functions, and cohort analysis into your query scripts.
  • Profile slow queries using execution plans; see our guide on SQL performance tuning.
  • Write a structured GitHub README.md highlighting business ROI and insights.
  • Test your query problem-solving skills interactively on Topfolio Practice.

How to Optimize SQL Projects for Hiring Manager Take-Home Tests

Hiring teams evaluate take-home SQL projects on code quality, not just numerical correctness:

  1. Consistent SQL Style Guide: Use uppercase for SQL keywords (SELECT, FROM, WHERE), lowercase snake_case for column identifiers (user_id, created_at), and 4-space indentation.
  2. Explicit Column Names: Never submit SELECT * in take-home solutions. Always name every selected column explicitly and alias computed columns intuitively (daily_active_users, revenue_run_rate).
  3. Comment Business Rationale: Add concise 1-line comments explaining why you chose a LEFT JOIN over an INNER JOIN or why you filtered out negative refund records.
  4. Include a Testing & Validation Query: At the end of your script, include audit queries that verify primary key uniqueness and check for dropped rows.

Discover more real-world projects in our SQL Tutorials hub and practice coding on Topfolio Practice.

Find public, high-volume transactional data for your projects in our curated Free Datasets Guide.

Build Production-Grade Data Projects

Explore hands-on guided projects with real-world datasets, industry reviews, and portfolio-ready architectures on Topfolio.

Explore Guided Projects

Frequently Asked Questions

What are the best SQL projects for data analyst resumes?

The best SQL projects solve real business problems: SaaS subscription churn analysis, e-commerce customer cohort retention, multi-touch marketing attribution, and financial transaction fraud detection using real-world public datasets.

How many SQL projects should I include in my portfolio?

Aim for 2 to 3 polished, end-to-end projects. Having two comprehensive projects featuring window functions, CTEs, and BI dashboard integration is far more impressive to hiring managers than 10 trivial toy queries.

Where can I find free datasets for SQL projects?

Top sources include Kaggle Datasets (e.g., Olist Brazilian E-Commerce, Spotify Streaming), Google BigQuery Public Datasets, GitHub public data repos, and classic database samples like Sakila, Northwind, and AdventureWorks.

Should I showcase raw SQL scripts or a full dashboard in my project?

A complete data portfolio project pairs reproducible SQL transformation scripts on GitHub with a visual dashboard (Tableau, Power BI, or Evidence.dev) and a concise one-page executive summary explaining business takeaways.

How do I prove my SQL projects demonstrate advanced skills?

Incorporate analytical window functions (RANK, LAG/LEAD), modular CTE architectures, indexing optimization with EXPLAIN plans, and cohort analysis rather than basic SELECT ... WHERE queries.

Anuj Saini

Written by

Anuj SainiFounder & Lead Instructor

Founder at Topfolio with 6+ years in data & analytics across JPMC, Ultrahuman, and high-growth startups. Sat on hiring panels, reviewed 500+ resumes, and writes practical SQL & data guides.