SELECT distinct order_id,
first(start_date) over (partition by order_id order by start_date
rows between unbounded preceding and unbounded following) as start_date,
last(status) over (partition by order_id order by start_date
rows between unbounded preceding and unbounded following) as status
FROM a_table;
1条答案
按热度按时间x4shl7ld1#
您需要在同一个窗口中运行两个独立的函数,分别用于起始日期和状态: