SQL Practice Workbook – 100 Exercises with Solutions
Learn SQL by writing real queries, solving practical challenges, and analyzing business data.
Are you learning SQL and looking for an effective way to practice your skills? Do you want to go beyond theoretical explanations and gain confidence in writing SQL queries independently?
SQL Practice Workbook is a hands-on learning resource featuring 100 practical SQL exercises, complete solutions, explanations, and a downloadable SQLite practice database.
Designed for beginners, aspiring data analysts, software testers, developers, and IT professionals, this workbook guides you from basic SQL statements to more advanced analytical queries.
What's Inside This Book?
100 Practical SQL Exercises
Work through 100 carefully organized challenges designed to develop your SQL skills progressively.
Start with simple data retrieval and filtering, then move into joins, aggregations, subqueries, common table expressions, window functions, and advanced business analysis.
10 Structured Chapters
The workbook organizes exercises into 10 chapters, allowing you to build a solid foundation before progressing to more complex topics.
Complete SQL Solutions
Every exercise includes a reference SQL query, an explanation of why the solution works, and a preview of the expected results.
Try solving each exercise yourself before checking the provided answer.
Realistic Retail Database
Practice using ShopLab, a fictional retail business database containing information about customers, products, categories, orders, order items, payments, and returns.
Explore relationships between tables and solve tasks inspired by everyday business reporting and data analysis.
Downloadable SQLite Database and Practice Resources
Access the companion GitHub repository to download the SQLite database and supporting resources.
The companion materials described in the book include:
Ready-to-use SQLite database
Database setup script
SQL exercise workspace
Reference SQL solutions
Expected query results
Optional Python answer checker
Practice Without a Database Server
The workbook uses SQLite, so you can practice locally without installing or configuring a separate database server.
A SQLite-compatible application and the downloadable database are all you need to get started.
Topics Covered
Chapter 1: Selecting and Filtering Data
Learn to retrieve records, select specific columns, apply filters, and organize query results.
Chapter 2: Conditions and Calculated Columns
Practice logical conditions, calculated values, column aliases, CASE expressions, and handling missing data.
Chapter 3: Aggregates and Grouping
Work with COUNT, SUM, AVG, MIN, MAX, GROUP BY, and HAVING to summarize datasets.
Chapter 4: Joins and Relationships
Explore relationships between tables using joins, including situations involving missing related records.
Chapter 5: Order Values, Payments, and Returns
Calculate business values, analyze payments, evaluate discounts, and work with order and return information.
Chapter 6: Subqueries and Set Operations
Develop your skills with nested queries and SQL set operations such as UNION, INTERSECT, and EXCEPT.
Chapter 7: Dates and Text
Practice date calculations, text manipulation, and reporting based on time periods.
Chapter 8: CTEs and Business Summaries
Use common table expressions, including recursive CTEs, to build structured business queries.
Chapter 9: Window Functions
Explore ROW_NUMBER, RANK, DENSE_RANK, running totals, and other analytical window functions.
Chapter 10: Analytical Challenges
Apply your knowledge to more advanced scenarios, including customer spending, product return rates, cohort retention, and business performance reporting.
Who Is This Book For?
Beginners learning SQL from scratch
Students looking for practical database exercises
Junior and experienced data analysts
Software testers and QA engineers working with databases
Backend developers who want to strengthen their SQL knowledge
Business analysts working with structured data
IT professionals preparing for SQL interviews
Anyone who wants to improve SQL skills through practice
How to Use This Workbook
Download the companion SQLite database.
Open the database using your preferred SQLite client.
Read an exercise and write your own SQL query.
Execute the query and examine the results.
Compare your solution with the reference answer.
Read the explanation and identify possible improvements.
Progress to the next exercise.
The workbook encourages active problem-solving rather than simply reading SQL examples.
Download the Practice Database
The companion database and supporting files are referenced in the following GitHub repository:
https://github.com/rafi9898/sql-database
The database is downloaded separately from the e-book.
Publication Details
Author: Rafał Podraza
Language: English
Format: Digital PDF
Length: 94 pages
Exercises: 100
Chapters: 10
Difficulty: Beginner to Advanced
Database: SQLite
Companion Resources: GitHub repository
Build Real SQL Skills Through Practice
Whether you are starting your SQL journey or improving your analytical skills, this workbook provides a structured way to practice writing queries, understanding data relationships, and solving business-oriented database challenges.
Stop just reading SQL. Start writing it!




