select
od.order_id,
c.customer_name,
a.order_date
from (
select
customer_id,
max(order_date) as order_date
from
orders
group by
customer_id
)a
inner join
orders as od
on
a.customer_id = od.customer_id
and
a.order_date = od.order_date
inner join
customers as c
on
c.customer_id = a.customer_id
order by
c.customer_name


京公网安备 11010502036488号