Most Active Customers, Ties Kept
Rank customers by their number of orders (most orders = rank 1, equal counts share a rank). Return customer_id, orders and order_rank for every customer whose rank is 3 or better (ties included, so there may be more than three rows). Sort by order_rank, then customer_id.
Hint 1
Count orders per customer in a CTE, then RANK() OVER (ORDER BY orders DESC).
Reference solution
WITH counts AS (
SELECT customer_id, COUNT(*) AS orders
FROM orders
GROUP BY customer_id
), ranked AS (
SELECT customer_id, orders, RANK() OVER (ORDER BY orders DESC) AS order_rank
FROM counts
)
SELECT customer_id, orders, order_rank
FROM ranked
WHERE order_rank <= 3
ORDER BY order_rank, customer_id;
The business question decides the function. "The top three customers" with ROW_NUMBER always gives exactly three rows, even if the third and fourth customer have the same number of orders, which is unfair to the fourth. "Everyone in the top three places" with RANK keeps all tied customers. Two CTEs separated by a comma are a clean way to chain the steps: count, then rank.