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