我想获取所有客户的最后一个订单的日期和移动#。 这是我的查询。
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 )
工作正常。但是没有按照o.order_datetime的asc顺序给我数据?
查询中的错误是什么?
答案 0 :(得分:1)
试试这个
ORDER BY DATE( o.order_datetime ) DESC