An online shop has two tables, customers and orders. Each order records which customer placed it (customer_id), the amount (amount), and the time it was placed (created_at). Write a single SELECT statement that counts how many orders each customer placed. The result has two columns: - customer_name : the customer's name - order_count : how many orders that customer placed Sort by customer name in ascending order. Write your query in solution.sql, and pressing 'Run test' runs it against a real database and shows the result table.
This challenge has you write a PostgreSQL SELECT statement that counts how many orders each customer placed. A table of customers and a table of orders come ready with data, and pressing 'Run test' runs your query against a real database and shows the result table. The result has two columns: one for the customer's name, one for their order count.
This problem is about "what quietly disappears when you pair two tables and count." A query that counts rows can look right on a few common rows, yet when one side has no match at all (a customer with no orders, say), the answer changes. Before trusting such a query, don't just skim a handful of common customers — run it for real and watch that every customer still has a row in the result.