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