SQL JOIN Practice Problems

Practice SQL JOIN with problems that go beyond matching two tables. Work with customers, orders, employees, and other related data to find records, combine information, and calculate results. Your queries run in a real database and are automatically checked against expected results using hidden data. Problems in this set: 148, free: 26.

Problems in this set: 148, free: 26

Start with a free problem

JOIN problems

Problems found: 110

Reset filters
  • MediumPremium
    PostgreSQL · MySQL · ClickHouse

    Each Client's Latest Purchased Device

    The CRM team is preparing an upsell campaign for clients who recently bought devices.

    Beeline
  • MediumPremium
    PostgreSQL · MySQL · ClickHouse

    Employee Workload by Task Count

    HR is preparing a summary of employee workloads. For each employee, count their assigned tasks (task_count). Include employees with no tasks and show a count of zero. Return name and task_count.

    Finstar
  • MediumPremium
    PostgreSQL · MySQL · ClickHouse

    Works Checked Out More Than 5 Times

    A library wants to identify popular works. Find works that have been checked out more than 5 times. Return title and checkout_count. Sort the result by checkout count in descending order.

    Cian
  • MediumPremium
    PostgreSQL · MySQL · ClickHouse

    Works That Have Never Been Checked Out

    A librarian is reviewing the catalog for works nobody has borrowed. Find works that have never been checked out, meaning they have no records in checkouts. Return all columns for those works.

    Cian
  • MediumPremium
    PostgreSQL · MySQL · ClickHouse

    Accounts of Companies with SBER in Their Names

    The sales team is looking for accounts belonging to companies whose names contain the substring SBER. For all such companies, return the account_id and account_type of their accounts.

    GlowByte
  • MediumPremium
    PostgreSQL · MySQL · ClickHouse

    Account Count by Company

    The finance department is preparing a summary of company contracts. For each company, count its accounts (account_count). Include companies with no accounts and report 0 for them.

    GlowByte
  • MediumPremium
    PostgreSQL · MySQL · ClickHouse

    Drivers with More Than One Ride

    A ride-hailing service wants to find drivers with multiple ride bookings. Find drivers who have more than one ride, counting all rides, including canceled ones. Return name and ride_count.

    Yandex
  • MediumPremium
    PostgreSQL · MySQL · ClickHouse

    Five Most-Watched TV Series

    A streaming platform is preparing a top-5 list of shows by viewership. For each series, sum viewer_count across all view records. Find the 5 series with the highest total viewer counts.

    IVI
  • MediumPremium
    PostgreSQL · MySQL · ClickHouse

    Salespeople with No Orders from RED

    Before meeting with RED, management wants to identify salespeople who have never handled an order from that company. Return those salespeople's names.

  • MediumPremium
    PostgreSQL · MySQL · ClickHouse

    Top Travelers by Total Distance

    A travel service is creating a leaderboard based on users' total travel distances. For each user, return their name and the sum of the distances of all their rides as travelled_distance.

  • MediumPremium
    PostgreSQL · MySQL · ClickHouse

    Climate Type by Country

    A weather service classifies countries by their average temperature in November 2019.

  • MediumPremium
    PostgreSQL · MySQL · ClickHouse

    Buyers and Their Orders in 2019

    An analyst is preparing a report on buyer behavior. For each user, return their user_id as buyer_id, their registration date (join_date), and the number of orders placed in 2019 (orders_in_2019).

What you will practice

  • Choose the right JOIN type for the expected result
  • Identify the keys that connect two or more tables
  • Keep unmatched records with LEFT JOIN when needed
  • Understand how JOIN conditions and WHERE filters interact

Common mistakes

  1. 1. A JOIN creates unexpected duplicates

    When one customer has several orders, joining the tables produces several rows for that customer. This can inflate counts and sums. Check whether the join keys are unique on either side, and compare the number of rows before and after the JOIN.

  2. 2. A WHERE filter removes unmatched rows

    A LEFT JOIN fills columns from the missing right-hand record with NULL. Filtering those columns in WHERE can remove the unmatched rows you intended to keep. Check whether records without matches are still present, and decide whether the condition belongs in ON or WHERE.

  3. 3. The wrong columns are joined

    Two columns with similar names are not necessarily related. Joining them can produce no matches or, worse, convincing but incorrect pairs of records. Check what each key represents, whether the data types are compatible, and whether a few known relationships appear correctly in the result.

  4. 4. INNER JOIN hides missing relationships

    INNER JOIN returns only matching records. If the problem asks for customers without orders or pages without likes, those rows will disappear. Before writing the query, decide whether unmatched records belong in the output. Test your choice using records that have no corresponding row.

Theory and courses

Frequently asked questions

Can I practice SQL JOIN for free?

Yes. Free problems in this set: 26. You can solve them without paying. After signing in, the free plan allows up to 3 new problems per day. Premium problems are visible in the list but require a subscription to solve.

Does the trainer show the correct JOIN query?

Reference solutions are not published. You write your own SQL, which runs against a real database. The trainer automatically checks the result against an expected result using hidden data. Problems include hints and an AI mentor to help you work through the logic.

When should I use LEFT JOIN instead of INNER JOIN?

Think about which rows must appear in the result. Use LEFT JOIN when every row from the left table should remain, even without a matching record on the right. INNER JOIN is appropriate when you only need matches. The difference becomes clear when you test missing relationships.

Why does my JOIN return more rows than expected?

The relationship may be one-to-many or many-to-many. A single row from one table can match several rows in another, producing multiple output rows. That is not always a mistake. First decide whether the problem expects every matching pair or one result per entity.

Do I need GROUP BY to solve JOIN problems?

Not always. Some problems only require connecting tables and selecting the right records. Others ask you to count related rows, calculate totals, or summarize the joined data. Start with straightforward joins, then move to problems that combine JOIN with aggregation.