Customer Placing Most Orders

ASKED IN INTERVIEW
2pts
Amazon

Problem Statement

Amazon logistics needs to identify its most frequent shoppers. Write an SQL query to find the customer_number of the customer who has placed the largest number of orders.

The test cases are designed so that exactly one customer will have placed more orders than any other customer.

Rules:

  • Output column: customer_number.
  • Only return the single customer with the most orders.
Tests your understanding of
Grouping, Aggregation and Sorting

Input Tables

orders
order_number(INTEGER)customer_number(INTEGER)order_date(DATE)
112026-02-01
222026-02-01
332026-02-02
432026-02-02
order_items
order_number(INTEGER)item_id(INTEGER)quantity(INTEGER)
11011
41025
customers
customer_number(INTEGER)customer_name(VARCHAR)
1Alice
2Bob
3Charlie

Expected Output

customer_number(INTEGER)
3

Tags

EasyASKED IN INTERVIEWGroupingAggregationSorting
10-15 min
85%

Hints