9. Highest Order Placing Customer

As a business, you want to identify which customer places the most orders. This is useful for targeting high-value customers with loyalty programs or marketing campaigns.

You are given a table named Orders that tracks customer orders.

╔═════════════════╦══════════╗
ā•‘   Column Name   ā•‘   Type   ā•‘
╠═════════════════╬══════════╣
ā•‘   order_number  ā•‘   int    ā•‘
║─────────────────┼──────────║
ā•‘ customer_number ā•‘   int    ā•‘
ā•šā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•©ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•
  • order_number: Unique order ID (Primary Key) for each order placed.
  • customer_number: ID of the customer who placed the order.

Write a query to find the customer_number of the customer who has placed the most orders. It is guaranteed that exactly one customer will have placed more orders than any other.

Example 1:

Example:

Input:

Orders Table

╔══════════════╦═════════════════╗
ā•‘ order_number ā•‘ customer_number ā•‘
╠══════════════╬═════════════════╣
ā•‘      1       ā•‘        1        ā•‘
║──────────────┼─────────────────║
ā•‘      2       ā•‘        2        ā•‘
║──────────────┼─────────────────║
ā•‘      3       ā•‘        3        ā•‘
║──────────────┼─────────────────║
ā•‘      4       ā•‘        3        ā•‘
ā•šā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•©ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•

Expected Output:

╔═════════════════╗
ā•‘ customer_number ā•‘
╠═════════════════╣
ā•‘        3        ā•‘
ā•šā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•

Explanation:

  • Customer 1 placed 1 order.
  • Customer 2 placed 1 order.
  • Customer 3 placed 2 orders (most orders).

Thus, the result is customer_number 3.

Still unsure what the problem is asking ?

Let’s go through a few more examples, step by step, to make it clearer.

Hints

0
Ā 
Test Case

Input:

Orders