Top Three Products per Category
For every category, return the three most expensive products: category_id, name, price. For equal prices the lower product_id comes first. Only categories 2, 3 and 5 are needed. Sort by category_id, then by price from high to low, then product_id.
Hint 1
Number the products inside each category by price (and product_id as tie-breaker), then keep numbers 1 to 3.
Reference solution
WITH ranked AS (
SELECT category_id, name, price, product_id,
ROW_NUMBER() OVER (PARTITION BY category_id ORDER BY price DESC, product_id) AS n
FROM products
WHERE category_id IN (2, 3, 5)
)
SELECT category_id, name, price
FROM ranked
WHERE n <= 3
ORDER BY category_id, price DESC, product_id;
LIMIT cuts the whole result, it knows nothing about groups. "Top N per group" is the textbook use of ROW_NUMBER() OVER (PARTITION BY group ORDER BY ...) followed by a filter on the number. Use RANK() instead if ties should all be kept, and ROW_NUMBER() if you want exactly N rows per group. Always include a tie-breaker in the window's ORDER BY so the result is repeatable.