Created
April 15, 2022 17:54
-
-
Save GGrassiant/32a4ad671195f7748303e8802404cd5d to your computer and use it in GitHub Desktop.
SQL Group and SubQuery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with group_orders as ( | |
SELECT customer_number, count(order_number) as numOfOrder | |
FROM orders | |
GROUP BY customer_number | |
) | |
SELECT customer_number | |
FROM orders | |
GROUP BY customer_number | |
HAVING count(order_number) = (SELECT MAX(numOfOrder) FROM group_orders) | |
#See https://leetcode.com/problems/customer-placing-the-largest-number-of-orders/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment