본문 바로가기
취준/코팅 테스트

[LeetCode] - 586. Customer Placing the Largest Number of Orders

by 소복소복뚜벅뚜벅 2024. 3. 25.

문제 

 

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.

 

 

문제 풀이 

SELECT customer_number 
FROM Orders 
GROUP BY customer_number 
ORDER BY COUNT(*) DESC 
LIMIT 1

 

 

 

오답 이유

1. Having으로 풀려고 했음. 

2. Order By 뒤에는 변수명만 들어간다고 착각함. 

3. DESC, LIMIT 1 하는 거 까먹음.