The Orders table has one row per order. Write a query that returns the customer_number of the customer who placed the largest number of orders.
Input Table(s)
Orders
| Column | Type | Meaning |
|---|
| order_number | INT | Identifier of the order |
| customer_number | INT | Customer who placed the order (NOT NULL) |
Primary key: order_number. A customer can appear in many rows.
Output Contract
-
One column:
customer_number
(INT).
-
Exactly one row, holding the customer with the most orders.
-
The result has a single row, so no ordering is required. No rounding applies.
Example
Orders
| order_number | customer_number |
|---|
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |
| 4 | 3 |
Expected result:
Customer 3 has two orders, while customers 1 and 2 have one each, so customer 3 is returned.
Constraints and Clarifications
-
Orders
contains at least one row.
-
Exactly one customer has placed more orders than every other customer, so the answer is unique and there is no tie to break.
-
customer_number
is never NULL.
-
order_number
is unique, so each row counts as one order.