Customers Without Orders
Find all customers who have never placed an order. Return columns: id, name, email.
Practice combining related tables with INNER JOIN and LEFT JOIN exercises. These 33 interactive challenges use real schemas and instant query validation.
Find all customers who have never placed an order. Return columns: id, name, email.
Concept guide
SQL JOINs combine rows from related tables. INNER JOIN keeps matching rows, while LEFT JOIN preserves every row from the left table and fills missing matches with NULL.
INNER JOIN returns only matching rows. LEFT JOIN returns every row from the left table and matching rows from the right table, using NULL when no match exists.
Show all departments and their employee count, including departments with no employees. Return columns: employee_count, department_name. Order results by: d.id.
Calculate total revenue (sum of total_amount) per customer, showing customer name and total revenue, sorted by revenue descending. Return columns: customer_name, total_revenue. Order results by: total_revenue DESC.
List each employee's full name alongside their department name. Use INNER JOIN. Return columns: last_name, first_name, department_name.
For each product, show the total quantity sold and total revenue from order_items. Include product name. Return columns: product_name, total_revenue, total_quantity. Order results by: total_revenue DESC.
List each managed employee together with their manager's name. Return columns: manager, employee. Order results by: e.id.
Show every product and its revenue, using zero when it has no sales. Return columns: revenue, product_name. Order results by: p.id.
Show each department name, employee count, and total payroll. Return columns: total_payroll, employee_count, department_name. Order results by: d.id.
Return the 1 orders with the highest totals, including customer names. Return columns: order_id, total_amount, customer_name. Order results by: o.total_amount DESC, o.id.
Return the 2 orders with the highest totals, including customer names. Return columns: order_id, total_amount, customer_name. Order results by: o.total_amount DESC, o.id.
Return the 3 orders with the highest totals, including customer names. Return columns: order_id, total_amount, customer_name. Order results by: o.total_amount DESC, o.id.
Return the 4 orders with the highest totals, including customer names. Return columns: order_id, total_amount, customer_name. Order results by: o.total_amount DESC, o.id.
Return the 5 orders with the highest totals, including customer names. Return columns: order_id, total_amount, customer_name. Order results by: o.total_amount DESC, o.id.
Return the 6 orders with the highest totals, including customer names. Return columns: order_id, total_amount, customer_name. Order results by: o.total_amount DESC, o.id.
Return the 7 orders with the highest totals, including customer names. Return columns: order_id, total_amount, customer_name. Order results by: o.total_amount DESC, o.id.
Return the 8 orders with the highest totals, including customer names. Return columns: order_id, total_amount, customer_name. Order results by: o.total_amount DESC, o.id.
List order items with quantity at least 1, including the product name. Return columns: order_id, quantity, unit_price, product_name. Order results by: oi.quantity DESC, oi.id.
List order items with quantity at least 2, including the product name. Return columns: order_id, quantity, unit_price, product_name. Order results by: oi.quantity DESC, oi.id.
List order items with quantity at least 3, including the product name. Return columns: order_id, quantity, unit_price, product_name. Order results by: oi.quantity DESC, oi.id.
List order items with quantity at least 4, including the product name. Return columns: order_id, quantity, unit_price, product_name. Order results by: oi.quantity DESC, oi.id.
List order items with quantity at least 5, including the product name. Return columns: order_id, quantity, unit_price, product_name. Order results by: oi.quantity DESC, oi.id.
List order items with quantity at least 6, including the product name. Return columns: order_id, quantity, unit_price, product_name. Order results by: oi.quantity DESC, oi.id.
List order items with quantity at least 7, including the product name. Return columns: order_id, quantity, unit_price, product_name. Order results by: oi.quantity DESC, oi.id.
List order items with quantity at least 8, including the product name. Return columns: order_id, quantity, unit_price, product_name. Order results by: oi.quantity DESC, oi.id.
Count each customer's orders placed on or after 2024-01-01. Return columns: order_count, customer_name. Order results by: order_count DESC, customer_name.
Count each customer's orders placed on or after 2024-01-12. Return columns: order_count, customer_name. Order results by: order_count DESC, customer_name.
Count each customer's orders placed on or after 2024-01-20. Return columns: order_count, customer_name. Order results by: order_count DESC, customer_name.
Count each customer's orders placed on or after 2024-02-01. Return columns: order_count, customer_name. Order results by: order_count DESC, customer_name.
Count each customer's orders placed on or after 2024-02-15. Return columns: order_count, customer_name. Order results by: order_count DESC, customer_name.
Count each customer's orders placed on or after 2024-03-01. Return columns: order_count, customer_name. Order results by: order_count DESC, customer_name.
Count each customer's orders placed on or after 2024-03-08. Return columns: order_count, customer_name. Order results by: order_count DESC, customer_name.
Count each customer's orders placed on or after 2024-03-12. Return columns: order_count, customer_name. Order results by: order_count DESC, customer_name.
Use a self LEFT JOIN to list every employee with their direct manager's first name. Return columns: id, first_name, manager_name. Order results by: e.id.
A one-to-many or many-to-many relationship can produce multiple result rows for one source row. Check the join keys and the relationship cardinality.