SQLRepPath
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
00/60 solved

Intermediate Joins · INNER JOIN

11. Orders with customer names

Concept: INNER JOINshow

JOIN combines rows from two tables wherever the ON condition matches, usually a foreign key such as orders.customer_id = customers.id. Give tables short aliases (o, c) and prefix columns with them.

Example (different data):

SELECT i.id, p.title
FROM order_items i
JOIN products p ON p.id = i.product_id;

Your task

Finance flags every order of $200 or more for manual review. Reviewers need the customer's name, not an id.

Return order_id, name (the customer's name) and amount for every order with an amount of at least 200, largest first.

Solution unlocks after 3 more tries

Starting Postgres in your browser…

query.sql
Output

Write a query and press Run Query (Ctrl/⌘ + Enter).