with o as( select customer_id,product_id,row_number()over(partition by customer_id order by order_date desc) as rk from orders) select o.customer_id,c.customer_name,p.product_name as latest_order from o join customers c on o.customer_id=c.customer_id join products p on o.product_id=p.product_id where o.rk=1 order by o.customer_id