
select * from stream group by `customer_id` order by unit_importance, updated_at
select a.*
from (
select s.*,
row_number() over (partition by `customer_id` order by unit_importance, updated_at desc) rn
from stream s
) a
where a.rn = 1