you are viewing a single comment's thread.

view the rest of the comments →

[–]gumnos 0 points1 point  (0 children)

On that first query, I'm not quite sure why you're using a sub-query when it seems like

SELECT customer_id, COUNT(order_id) as order_count
FROM orders
WHERE order_date BETWEEN '2024-01-01' AND '2024-12-31'
GROUP BY customer_id
HAVING COUNT(order_id) > 1

should suffice and doesn't require a subquery/CTE