{ "data": { "question": { "questionId": "586", "questionFrontendId": "586", "boundTopicId": null, "title": "Customer Placing the Largest Number of Orders", "titleSlug": "customer-placing-the-largest-number-of-orders", "content": "
Table: Orders
\n+-----------------+----------+\n| Column Name | Type |\n+-----------------+----------+\n| order_number | int |\n| customer_number | int |\n+-----------------+----------+\norder_number is the primary key (column with unique values) for this table.\nThis table contains information about the order ID and the customer ID.\n\n\n
\n\n
Write a solution to find the customer_number
for the customer who has placed the largest number of orders.
The test cases are generated so that exactly one customer will have placed more orders than any other customer.
\n\nThe result format is in the following example.
\n\n\n
Example 1:
\n\n\nInput: \nOrders table:\n+--------------+-----------------+\n| order_number | customer_number |\n+--------------+-----------------+\n| 1 | 1 |\n| 2 | 2 |\n| 3 | 3 |\n| 4 | 3 |\n+--------------+-----------------+\nOutput: \n+-----------------+\n| customer_number |\n+-----------------+\n| 3 |\n+-----------------+\nExplanation: \nThe customer with number 3 has two orders, which is greater than either customer 1 or 2 because each of them only has one order. \nSo the result is customer_number 3.\n\n\n
\n
Follow up: What if more than one customer has the largest number of orders, can you find all the customer_number
in this case?
MySQL 8.0
.
mssql server 2019
.
Oracle Sql 11.2
.
Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0
\"], \"postgresql\": [\"PostgreSQL\", \"PostgreSQL 16
\"]}", "libraryUrl": null, "adminUrl": null, "challengeQuestion": null, "__typename": "QuestionNode" } } }