LeetCode 586. Customer Placing the Largest Number of Orders
考点 | 难度 |
---|---|
Database | Easy |
题目
Write an SQL query 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.
The query result format is in the following example.
思路
先排序,再筛选排名第一的customer_number
。
答案
select customer_number
from Orders
group by customer_number
order by count(*) desc
limit 1