Reputation: 2644
Question,
You are given the table "ORDERS"
Return the customerNumber to the customer that has placed the highest number of order(it is guaranteed that there is only one customer with the most orders).
My guess was to return highest repeated customer number but couldn't get the exact syntax.
My Answer (Doesn't Work)
SELECT 'customerNumber'
FROM 'ORDERS'
GROUP BY 'customerNumber'
ORDER BY COUNT(*)
DESC LIMIT 1;
Upvotes: 1
Views: 2938
Reputation: 9
SELECT customer_number FROM orders GROUP BY customer_number ORDER BY count(order_number) DESC LIMIT 1;
Upvotes: 0
Reputation: 2644
SELECT customerNumber
FROM ORDERS
GROUP BY customerNumber
ORDER BY COUNT(*)
DESC LIMIT 1;
Upvotes: 4