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

  • EasyFree
    PostgreSQL · MySQL · ClickHouse

    Customers with Unexpired Applications

    Tochka Bank's CRM helps managers find customers who still have unexpired product applications.

    Tochka
  • EasyFree
    PostgreSQL · MySQL · ClickHouse

    Top 3 Cities by Completed Trades

    Robinhood is analyzing trading activity by city. Find the three cities with the most completed trades (status = 'Completed'). Return each city name and its number of completed trades as total_orders.

    Robinhood
  • EasyFree
    PostgreSQL · MySQL · ClickHouse

    Spare Data Center Capacity

    The Microsoft Azure team is evaluating unused data center capacity. For each data center, calculate spare capacity as monthly_capacity − monthly_demand. If demand data is missing, treat demand as 0.

    Microsoft
  • EasyFree
    PostgreSQL · MySQL · ClickHouse

    Signup Confirmation on the Next Day

    TikTok is analyzing new user behavior. Find users who confirmed their email (signup_action = 'Confirmed') via SMS on the calendar day immediately after signing up, not on the signup date itself.

    TikTok
  • EasyFree
    PostgreSQL · MySQL · ClickHouse

    Employees Who Earn More Than Their Managers

    The HR department is looking for pay anomalies: some employees earn more than their immediate managers. Find all such employees and return their ID and name.

  • EasyFree
    PostgreSQL · MySQL · ClickHouse

    Bands That Departed from Vladivostok

    Regional news outlets in the Russian Far East want to know which bands departed on tour from Vladivostok. Return their names without duplicates.

  • EasyFree
    PostgreSQL · MySQL · ClickHouse

    Unique Fans at Each Concert

    A concert promoter is preparing an attendance report. For each concert, return its id and the number of fans who attended. Include concerts with no attendees, showing a count of 0.

  • EasyFree
    PostgreSQL · MySQL · ClickHouse

    Wards Where Dr. Bennett Has Seen Patients

    The staffing department is preparing a duty schedule for Dr. Bennett and wants to see which wards he has worked in. Return all wards where he has seen patients.

  • EasyFree
    PostgreSQL · MySQL · ClickHouse

    Bennett's Appointments on August 30, 2019

    During a review of the shift on August 30, 2019, the chief physician wants an exact count of appointments conducted by Dr. Bennett. Count how many appointments he conducted that day.

  • EasyFree
    PostgreSQL · MySQL · ClickHouse

    Doctors Who Saw Patients in Neurology Wards

    The head of neurology is preparing a list of colleagues to recognize. The list should include doctors who have seen patients in neurology wards at least once.

  • EasyFree
    PostgreSQL · MySQL · ClickHouse

    Facebook Pages with No Likes

    Facebook wants to identify pages that have never received a like. Return the IDs of these pages in a column named page_id.

    Facebook (Meta)
  • EasyFree
    PostgreSQL · MySQL · ClickHouse

    Total Account Balance per Client

    The finance department is preparing an overview of client account balances. For each client, calculate the sum of the balances across all their accounts and return the client's name and total_balance.

    Sberbank

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.