SQL exercises with solutions

47 practice problems from the 15 lessons of the Database Management Systems course, in lesson order and from easy to hard inside each lesson. Open a problem, write your code and press Submit: the tests run in your browser and nothing is sent to a server.

16 easy problems 16 medium problems 15 hard problems

Databases and tables

3 problems · Read the lesson

Creating tables and adding rows

3 problems · Read the lesson

Choosing rows and columns: SELECT and WHERE

3 problems · Read the lesson

Sorting, limiting and DISTINCT

4 problems · Read the lesson

Changing and deleting rows

3 problems · Read the lesson

Counting and totals: GROUP BY and HAVING

4 problems · Read the lesson

Keys and constraints

3 problems · Read the lesson

Joining tables

3 problems · Read the lesson

Relational algebra

3 problems · Read the lesson

Subqueries and WITH

3 problems · Read the lesson

CASE, views and set operations

3 problems · Read the lesson

Designing a database: the ER model

3 problems · Read the lesson

Normalization

3 problems · Read the lesson

Indexes and how queries find rows

3 problems · Read the lesson

Transactions and concurrency

3 problems · Read the lesson