Skip to content

1565. Unique Orders and Customers Per Month

1
2
3
4
5
6
7
SELECT
  DATE_FORMAT(order_date, '%Y-%m') AS month,
  COUNT(order_id) AS order_count,
  COUNT(DISTINCT customer_id) AS customer_count
FROM Orders
WHERE invoice > 20
GROUP BY 1;