wrap final select in cte
This commit is contained in:
parent
420d93d9bf
commit
34985f3de1
1 changed files with 96 additions and 86 deletions
|
|
@ -22,8 +22,9 @@ with
|
||||||
amount_without_taxes_in_gbp
|
amount_without_taxes_in_gbp
|
||||||
from {{ ref("int_core__guest_journey_payments") }}
|
from {{ ref("int_core__guest_journey_payments") }}
|
||||||
where product_name = 'CHECKINCOVER' and payment_status in ('PAID', 'REFUNDED')
|
where product_name = 'CHECKINCOVER' and payment_status in ('PAID', 'REFUNDED')
|
||||||
)
|
),
|
||||||
select
|
pre_feature_flag_verification_requests as (
|
||||||
|
select
|
||||||
vr.id_verification_request,
|
vr.id_verification_request,
|
||||||
vr.uuid_verification_request,
|
vr.uuid_verification_request,
|
||||||
vr.id_verification_set,
|
vr.id_verification_set,
|
||||||
|
|
@ -35,7 +36,8 @@ select
|
||||||
b.id_accommodation,
|
b.id_accommodation,
|
||||||
vr.is_verification_request_complete,
|
vr.is_verification_request_complete,
|
||||||
(
|
(
|
||||||
p.total_amount_in_txn_currency is not null and not b.check_in_sits_in_future
|
p.total_amount_in_txn_currency is not null
|
||||||
|
and not b.check_in_sits_in_future
|
||||||
) as is_past_check_in,
|
) as is_past_check_in,
|
||||||
(
|
(
|
||||||
p.total_amount_in_txn_currency is not null
|
p.total_amount_in_txn_currency is not null
|
||||||
|
|
@ -44,7 +46,8 @@ select
|
||||||
) as is_awaiting_check_in,
|
) as is_awaiting_check_in,
|
||||||
p.total_amount_in_txn_currency is not null as cover_was_purchased,
|
p.total_amount_in_txn_currency is not null as cover_was_purchased,
|
||||||
(
|
(
|
||||||
p.total_amount_in_txn_currency is null and vr.is_verification_request_complete
|
p.total_amount_in_txn_currency is null
|
||||||
|
and vr.is_verification_request_complete
|
||||||
) as cover_was_rejected,
|
) as cover_was_rejected,
|
||||||
vr.verification_url,
|
vr.verification_url,
|
||||||
vr.callback_url,
|
vr.callback_url,
|
||||||
|
|
@ -95,17 +98,24 @@ select
|
||||||
ccp.checkin_cover_limit_amount_local_curr
|
ccp.checkin_cover_limit_amount_local_curr
|
||||||
* (p.total_amount_in_gbp / p.total_amount_in_txn_currency)
|
* (p.total_amount_in_gbp / p.total_amount_in_txn_currency)
|
||||||
)::numeric(18, 4) as checkin_cover_limit_amount_in_gbp
|
)::numeric(18, 4) as checkin_cover_limit_amount_in_gbp
|
||||||
from int_core__verification_requests vr
|
from int_core__verification_requests vr
|
||||||
left join int_core__bookings b on vr.id_verification_request = b.id_verification_request
|
left join
|
||||||
left join
|
int_core__bookings b
|
||||||
|
on vr.id_verification_request = b.id_verification_request
|
||||||
|
left join
|
||||||
stg_core__verification_set_to_verification_type vstvt
|
stg_core__verification_set_to_verification_type vstvt
|
||||||
on vr.id_verification_set = vstvt.id_verification_set
|
on vr.id_verification_set = vstvt.id_verification_set
|
||||||
left join
|
left join
|
||||||
check_in_cover_payments p on vr.id_verification_request = p.id_verification_request
|
check_in_cover_payments p
|
||||||
left join
|
on vr.id_verification_request = p.id_verification_request
|
||||||
int_core__check_in_cover_prices ccp on p.currency = ccp.local_currency_iso_4217
|
left join
|
||||||
left join int_core__unified_user gu on gu.id_user = vr.id_user_guest
|
int_core__check_in_cover_prices ccp
|
||||||
-- 15 is Check-in cover.
|
on p.currency = ccp.local_currency_iso_4217
|
||||||
-- Adding this condition results in only keeping guest journeys that offered the
|
left join int_core__unified_user gu on gu.id_user = vr.id_user_guest
|
||||||
-- check-in cover
|
-- 15 is Check-in cover.
|
||||||
where vstvt.id_verification_type = 15
|
-- Adding this condition results in only keeping guest journeys that offered the
|
||||||
|
-- check-in cover
|
||||||
|
where vstvt.id_verification_type = 15
|
||||||
|
)
|
||||||
|
select *
|
||||||
|
from pre_feature_flag_verification_requests
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue