SQL JOIN practice exercises

SQL · Lesson 3

Ctrl/⌘ + Enter to run

The 7 exercises in this lesson

  1. Orders only store a customer_id. Return each order's id together with the name of the customer who placed it.
  2. Return the customer name and amount of every order placed by a customer from TX.
  3. Return each customer's name and the total amount they've spent. Only customers with orders.
  4. Now every customer, even those who never ordered: return each name and their number of orders (0 if none).
  5. Who hasn't ordered yet? Return the names of customers with no orders.
  6. List every customer next to each Fern order they placed: the customer's name and the order's amount (its price), one row per Fern order. Customers without a Fern order still appear once, with an empty amount.
  7. Last one. How many different customers in each state have placed at least one order? Return the state and the number.

More SQL practice

SQL practice onlineSQL skills testSQL SELECT practiceSQL GROUP BY practiceSQL subquery practicePrimary and foreign key practiceDatabase normalization practiceSQL constraints practiceExcel practice onlineLearn to read financial statements