Learn SQL with 100 Coding Exercises Master Database Quizzes

Robert Jul 13, 2026

Whether you're a beginner or an experienced developer aiming to enhance your skills, learning Structured Query Language (SQL) is a pivotal step in your journey. SQL is a standard language for managing and manipulating relational databases, and it's extensively used across various industries. The best way to master SQL is through practical exercises that help you understand its concepts better. Here, we've compiled a list of 100 SQL coding exercises to help you grasp and apply its fundamentals.

Learn SQL Fast 🚀 | Beginner SQL Commands Cheat Sheet for Data Analysts
Learn SQL Fast 🚀 | Beginner SQL Commands Cheat Sheet for Data Analysts

These exercises are designed to cover various aspects of SQL, from basic concepts to advanced topics. They're suitable for all levels, from beginners just starting with SQL to intermediate learners seeking to deepen their understanding. So, let's dive right in and explore these exercises under two main topics: SQL Basics and Advanced SQL Concepts.

SQL Basics Cheat Sheet for Beginners | Learn SQL Fast 💻
SQL Basics Cheat Sheet for Beginners | Learn SQL Fast 💻

SQL Basics

Before delving into more complex SQL operations, it's crucial to understand its basics. This section covers foundational topics like data definition, data manipulation, and basic queries.

Sql Cheat Sheet, Learn Sql, Learn Web Development, Excel Tutorials, Sql Server, Career Options, Data Analyst, Data Scientist, Data Analysis
Sql Cheat Sheet, Learn Sql, Learn Web Development, Excel Tutorials, Sql Server, Career Options, Data Analyst, Data Scientist, Data Analysis

Data Definition

Data definition involves creating and modifying database objects such as tables, views, and indexes.

SQL Basics Every Beginner Must Learn | Ultimate SQL Cheat Sheet
SQL Basics Every Beginner Must Learn | Ultimate SQL Cheat Sheet

**Exercise 1**: Create a database named 'Bookstore'.

**Exercise 2**: Create a table named 'Books' with columns 'ID', 'Title', 'Author', 'Price', and 'PublishDate'.

Data Manipulation

SQL Quick Notes Cheat Sheet | SQL Queries, Joins, Functions & Database Commands for Beginners
SQL Quick Notes Cheat Sheet | SQL Queries, Joins, Functions & Database Commands for Beginners

Data manipulation revolves around adding, updating, and removing data from your tables.

**Exercise 3**: Insert five records into the 'Books' table.

**Exercise 4**: Update the price of 'Clean Code' by Robert C. Martin.

Learn SQL just by investing 30 minutes a day within 30 Days
Learn SQL just by investing 30 minutes a day within 30 Days

Basic Queries

Basic queries help you retrieve data based on specific criteria. They typically use clauses like WHERE, SELECT, and DISTINCT.

a sheet of paper that has some notes on it with words and symbols in the middle
a sheet of paper that has some notes on it with words and symbols in the middle
SQL in 60 days
SQL in 60 days
SQL cheat sheet
SQL cheat sheet
SQL Basics For Beginners
SQL Basics For Beginners
SQL Subqueries Explained with Examples | Beginner SQL Tutorial
SQL Subqueries Explained with Examples | Beginner SQL Tutorial
How to Learn SQL Fast | Beginner Guide 🚀
How to Learn SQL Fast | Beginner Guide 🚀
7 SQL QUERIES EVERY STUDENT SHOULD MASTER
7 SQL QUERIES EVERY STUDENT SHOULD MASTER
7 SQL Commands Every Beginner Must Know
7 SQL Commands Every Beginner Must Know
SQL
SQL
Top 20 SQL Queries for Practice | SQL Cheat Sheet for Beginners & Interviews
Top 20 SQL Queries for Practice | SQL Cheat Sheet for Beginners & Interviews
SQL Joins Explained 🚀 | Beginner Data Analyst SQL Guide
SQL Joins Explained 🚀 | Beginner Data Analyst SQL Guide
Top SQL Queries Every Fresher Should Practice
Top SQL Queries Every Fresher Should Practice
SQL Cheat Sheet for Beginners
SQL Cheat Sheet for Beginners
SQL SUBSTRING() Explained with Examples | Extract Text in SQL Server
SQL SUBSTRING() Explained with Examples | Extract Text in SQL Server
SQL Aggregate Functions Cheat Sheet for Beginners
SQL Aggregate Functions Cheat Sheet for Beginners
SQL Joins Explained with Examples | Complete JOIN Cheat Sheet for Beginners
SQL Joins Explained with Examples | Complete JOIN Cheat Sheet for Beginners
SQL SUM() Explained with Examples | Beginner SQL Tutorial
SQL SUM() Explained with Examples | Beginner SQL Tutorial
SQL Cheat Sheet for Beginners | Essential Commands & Queries
SQL Cheat Sheet for Beginners | Essential Commands & Queries
SQL CROSS JOIN Explained with Examples | Beginner SQL Tutorial
SQL CROSS JOIN Explained with Examples | Beginner SQL Tutorial

**Exercise 5**: Retrieve all columns from the 'Books' table.

**Exercise 6**: Retrieve distinct authors from the 'Books' table.

Advanced SQL Concepts

Once you're comfortable with the basics, it's time to explore advanced SQL concepts that unlock more complex operations and increase your querying efficiency.

JOINs

JOINs allow you to combine rows from two or more tables based on a related column between them.

**Exercise 7**: Write a SQL query to retrieve book titles along with their authors' names. Assume you have an 'Authors' table with 'ID', 'Name', and 'Nationality' columns and a 'Books' table with 'ID', 'Title', and 'AuthorID' columns.

Subqueries

Subqueries are queries embedded within another query. They allow you to use the result of a subquery as part of an expression in the main query.

**Exercise 8**: Find the second-highest price in the 'Books' table.

Aggregations and Grouping

SQL aggregations like COUNT(), SUM(), AVG(), MIN(), and MAX() help you summarize and analyze data. You can group results by using the GROUP BY clause.

**Exercise 9**: Calculate the total price and average price of books authored by each author.

Indexing

Indexes improve the performance of data retrieval operations. They're like an index at the end of a book, helping you find specific information quickly.

**Exercise 10**: Create an index on the 'Title' column in the 'Books' table.

Embarking on this 100-exercise journey will not only help you learn SQL but also give you a solid foundation to build upon. With practice, you'll gain the confidence and skills needed to tackle more complex database tasks. So, start coding, and happy learning!