[SQL 문제 풀이] Customer Placing the Largest Number of Orders (가장 많은 주문을 하는 고객)

Stupefyee's avatar
Jun 04, 2025
[SQL 문제 풀이] Customer Placing the Largest Number of Orders (가장 많은 주문을 하는 고객)
notion image
가장 많은 주문을 한 고객을 위해 customer_number를 찾기 위한 솔루션을 작성하세요. 테스트 케이스는 한 고객이 다른 고객보다 더 많은 주문을 할 수 있도록 생성됩니다.
 

내가 작성한 쿼리

Oracle

SELECT customer_number FROM ( SELECT customer_number, COUNT(*) AS count FROM Orders GROUP BY customer_number ORDER BY count DESC ) WHERE ROWNUM = 1;

MySQL

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

차이점

  • 상위 결과값 1개를 출력하는 방식의 차
Share article

stupefyee