select
orders.order_id,
customer_name,
orders.order_date
from
(
select
customer_id,
max(order_date) as order_date
from
orders
group by
customer_id
) as t1
left join orders on t1.order_date = orders.order_date
and t1.customer_id = orders.customer_id
left join customers on customers.customer_id=orders.customer_id
order by customer_name asc

京公网安备 11010502036488号