Changed to service_detail_updated_at_utc
This commit is contained in:
parent
43742355f0
commit
03bbf54e14
1 changed files with 5 additions and 4 deletions
|
|
@ -22,7 +22,7 @@ with
|
||||||
id_booking,
|
id_booking,
|
||||||
trim(unnested_service) as service_name,
|
trim(unnested_service) as service_name,
|
||||||
service_status,
|
service_status,
|
||||||
case when service_name like '% OR %' then 2 else 1 end as rank
|
service_detail_updated_at_utc
|
||||||
from
|
from
|
||||||
int_core__booking_service_detail,
|
int_core__booking_service_detail,
|
||||||
lateral unnest(string_to_array(service_name, ' OR ')) as unnested_service
|
lateral unnest(string_to_array(service_name, ' OR ')) as unnested_service
|
||||||
|
|
@ -32,11 +32,12 @@ with
|
||||||
id_booking,
|
id_booking,
|
||||||
service_name,
|
service_name,
|
||||||
service_status,
|
service_status,
|
||||||
rank,
|
service_detail_updated_at_utc,
|
||||||
row_number() over (
|
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
|
) as row_num
|
||||||
from expanded_booking_services
|
from expanded
|
||||||
),
|
),
|
||||||
unnested_booking_services as (
|
unnested_booking_services as (
|
||||||
select id_booking, service_name, service_status
|
select id_booking, service_name, service_status
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue