SELECT customer_id
SELECT customer_id, SUM(order_amount) as total_orders, MAX(order_date) as latest_order_date
FROM orders
WHERE order_date < DATE_SUB(NOW(), INTERVAL 30 DAY)
GROUP BY customer_id
HAVING total_orders > 1000;
SELECT customer_id, SUM(order_amount) as total_orders, MAX(order_date) as latest_order_date
FROM orders
WHERE order_date < DATE_SUB(NOW(), INTERVAL 30 DAY)
GROUP BY customer_id
HAVING total_orders > 1000;