Remove duplicates
This commit is contained in:
parent
ef03c0b60f
commit
a072a426dd
1 changed files with 17 additions and 5 deletions
|
|
@ -6,14 +6,28 @@
|
|||
unique_key=["date", "id_deal", "has_payment", "has_id_check"],
|
||||
)
|
||||
}}
|
||||
with
|
||||
ranked_bookings as (
|
||||
select
|
||||
*,
|
||||
row_number() over (
|
||||
partition by id_verification_request order by check_in_date_utc asc
|
||||
) as rn
|
||||
from {{ ref("int_core__bookings") }}
|
||||
),
|
||||
bookings as (select * from ranked_bookings where rn = 1)
|
||||
select
|
||||
-- Unique Key --
|
||||
b.check_in_date_utc as date,
|
||||
coalesce(icuh.id_deal, 'UNSET') as id_deal,
|
||||
case
|
||||
when vp.id_verification_to_payment is null then 'W/O Payment' else 'With Payment'
|
||||
when vp.id_verification_to_payment is null
|
||||
then 'W/O Payment'
|
||||
else 'With Payment'
|
||||
end as has_payment,
|
||||
case when v.id_verification is null then 'W/O Id Check' else 'With Id Check' end as has_id_check,
|
||||
case
|
||||
when v.id_verification is null then 'W/O Id Check' else 'With Id Check'
|
||||
end as has_id_check,
|
||||
-- Dimensions --
|
||||
coalesce(
|
||||
icd.main_billing_country_iso_3_per_deal, 'UNSET'
|
||||
|
|
@ -85,9 +99,7 @@ select
|
|||
end
|
||||
) as average_csat_score
|
||||
from {{ ref("int_core__verification_requests") }} as vr
|
||||
inner join
|
||||
{{ ref("int_core__bookings") }} as b
|
||||
on b.id_verification_request = vr.id_verification_request
|
||||
inner join bookings as b on b.id_verification_request = vr.id_verification_request
|
||||
left join
|
||||
{{ ref("int_core__user_host") }} as icuh on vr.id_user_host = icuh.id_user_host
|
||||
left join {{ ref("int_core__deal") }} as icd on icuh.id_deal = icd.id_deal
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue