Changed to service_detail_updated_at_utc

This commit is contained in:
Joaquin Ossa 2025-02-13 14:52:38 +01:00
parent 43742355f0
commit 03bbf54e14

View file

@ -22,7 +22,7 @@ with
id_booking,
trim(unnested_service) as service_name,
service_status,
case when service_name like '% OR %' then 2 else 1 end as rank
service_detail_updated_at_utc
from
int_core__booking_service_detail,
lateral unnest(string_to_array(service_name, ' OR ')) as unnested_service
@ -32,11 +32,12 @@ with
id_booking,
service_name,
service_status,
rank,
service_detail_updated_at_utc,
row_number() over (
partition by id_booking, service_name order by rank asc -- Prioritize rank 1 first
partition by id_booking, service_name
order by service_detail_updated_at_utc desc -- Prioritize the most recent date
) as row_num
from expanded_booking_services
from expanded
),
unnested_booking_services as (
select id_booking, service_name, service_status