SQL SELECT Exercises

Get comfortable retrieving exactly the data you need with SQL SELECT exercises. Practice choosing columns, filtering rows with conditions, sorting results, and limiting the output. Each query runs in a real database and is checked against expected results using hidden data. Problems in this collection: 224, free: 127.

Problems in this set: 224, free: 127

Start with a free problem

SELECT and WHERE problems

Problems found: 55

Reset filters
  • EasyFree
    PostgreSQL · MySQL · ClickHouse

    Medications Costing More Than 6 Euros

    The pharmacy is reviewing its price tags. Return the name and price columns for all medications costing more than 6 euros. Sort the result by price in descending order, from most to least expensive.

  • EasyFree
    PostgreSQL · MySQL · ClickHouse

    Parts with Unfinished Assembly

    Tesla is analyzing bottlenecks in its production process. The parts_assembly table contains only parts already in production: each row represents one assembly step for a part, and a missing…

    Tesla
  • EasyFree
    PostgreSQL · MySQL · ClickHouse

    All Registered Fans

    A tour promoter needs a complete list of registered fans to send invitations to a private performance. Return the names of all fans in the database.

  • EasyFree
    PostgreSQL · MySQL · ClickHouse

    Names Ending in man

    The team running a pre-concert trivia quiz is looking for fans whose names end in man, as a nod to the band's track with that title. Return those fans' names.

  • EasyFree
    PostgreSQL · MySQL · ClickHouse

    Concert Venue Types in Moscow

    A concert producer in Moscow is preparing a presentation about the types of venues that have hosted concerts in the city. Return all distinct venue types for concerts held in Moscow.

  • EasyFree
    PostgreSQL · MySQL

    Trips Departing from Paris

    The tour logistics team is mapping out trips departing from Paris, including each destination and travel time.

  • EasyFree
    PostgreSQL · MySQL · ClickHouse

    Fans with the Longest Full Names

    A merchandise designer wants to see whether the longest fan names will fit on the largest badge size. Find all fans whose full names are tied for the greatest length.

  • EasyFree
    PostgreSQL · MySQL · ClickHouse

    Oldest Club Member

    The club president wants to send a warm greeting to the oldest member. Find and return the name of the club member with the earliest date of birth.

  • EasyFree
    PostgreSQL · MySQL · ClickHouse

    Patients with Maple Ave in Their Address

    A social worker is visiting patients on Maple Ave to offer a home monitoring program. Return all columns for patients whose addresses contain the substring Maple Ave.

  • EasyFree
    PostgreSQL · MySQL · ClickHouse

    Start Time of the 4th Slot

    The time slot schedule was recently changed, and the administrator needs to check that the 4th slot starts at the correct time. Return the start time of the slot where id = 4.

  • EasyFree
    PostgreSQL · MySQL · ClickHouse

    Appointment Duration from Slot 2 to Slot 4

    A patient has three consecutive procedures scheduled and wants to know how much time they will spend at the hospital.

  • EasyFree
    PostgreSQL · MySQL · ClickHouse

    Passengers with .by Email Addresses

    The platform's marketing team is preparing a special offer for customers from Belarus. Return all information about passengers whose email addresses end with .by.

What you will practice

  • Select specific columns instead of returning the entire table
  • Combine WHERE conditions using AND, OR, and parentheses
  • Sort records in ascending or descending order
  • Use LIMIT together with a meaningful ORDER BY

Common mistakes

  1. 1. Mixing AND and OR without parentheses

    AND has higher precedence than OR in SQL. Reading a condition from left to right can lead to a different interpretation than the database uses. Break complex filters into logical parts, add parentheses where needed, and test rows that meet only some of the conditions.

  2. 2. Using LIMIT without a defined order

    LIMIT restricts how many rows are returned, but it does not choose the newest, cheapest, or highest-ranked records. Without ORDER BY, the result order is not guaranteed. If a problem asks for top or latest entries, identify the sorting rule before applying LIMIT.

  3. 3. Comparing NULL with an equals sign

    NULL represents a missing value, so = NULL does not work like an ordinary equality check. The condition may silently exclude records you expected to see. Use the appropriate NULL check and consider whether records with missing values should be included or excluded.

  4. 4. Sorting numeric-looking text as numbers

    Values stored as text follow string sorting rules, which can produce a different order from numeric sorting. Dates stored as strings can cause similar surprises. Check the column's data type and inspect the first few returned rows before assuming the ordering is correct.

Theory and courses

Frequently asked questions

Are there free SQL SELECT exercises?

Yes. Free exercises in this collection: 127. With the free plan, you can sign in and solve up to 3 new problems per day without paying. Premium exercises remain visible in the catalog but require a subscription to solve.

How are my SELECT queries checked?

Your SQL runs in a real database, using PostgreSQL, MySQL, ClickHouse, or BigQuery depending on the problem. The result is automatically compared with an expected result using hidden data. This makes it worth checking the selected columns, returned rows, and required ordering carefully.

What is the difference between WHERE and ORDER BY?

WHERE determines which rows qualify for the result. ORDER BY determines their sequence. Sorting does not remove unwanted records, and filtering does not guarantee their order. Read the selection and sorting requirements separately, then make sure your query handles both.

Why does LIMIT sometimes return different rows?

Without ORDER BY, a database does not guarantee the order of returned records. LIMIT simply takes a portion of that result. If you need a predictable set of first rows, specify the sorting criteria. When values tie, an additional sorting column may be necessary.

Can I start with SELECT before learning JOIN?

Yes. Understanding tables, rows, columns, and basic filtering is enough to begin. SELECT exercises help you practice retrieving and organizing data from individual tables. Once those operations feel familiar, combining multiple tables with JOIN becomes much easier to reason about.