# #586 Customer Placing the Largest Number of Orders

#### [https://leetcode.com/problems/customer-placing-the-largest-number-of-orders/](https://leetcode.com/problems/customer-placing-the-largest-number-of-orders/)

{% tabs %}
{% tab title="MS SQL Server" %}
```sql
SELECT TOP 1 customer_number
FROM Orders
GROUP BY customer_number
ORDER BY COUNT(*) DESC;
```



```sql
SELECT customer_number
FROM (
    SELECT customer_number, row_number() 
    OVER (ORDER BY COUNT(DISTINCT order_number) DESC) rn
    FROM Orders
    GROUP BY customer_number) a
WHERE rn = 1
```
{% endtab %}
{% endtabs %}
