/*要用到的信息
orders :order_date,customer_id,product_id
products:product_id,product_name
customers:customer_id,customer_name
*/
select t.customer_id
,customer_name
,latest_order
from(
select o.customer_id
,customer_name
,product_name as latest_order
,order_date
,row_number() over(partition by o.customer_id order by order_date desc) as rk
from customers c
join orders o on o.customer_id = c.customer_id
join products p on p.product_id = o.product_id
) t
where rk = 1
order by customer_id