Reputation: 9212
I want to get the date of last order placed and mobile# for all the customers. This is my query.
SELECT c.customer_id, c.mobile, COALESCE( MAX( o.order_datetime ) , '0000-00-00 00:00:00' ) AS last_order_date
FROM table_orders AS o
RIGHT JOIN table_customers AS c ON o.customer_id = c.customer_id
GROUP BY c.customer_id
ORDER BY DATE( o.order_datetime )
It works fine. But not giving me data in asc order of o.order_datetime?
What is the error in query?
Upvotes: 2
Views: 3759