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
|
||||
from {{ ref("int_core__guest_journey_payments") }}
|
||||
where product_name = 'CHECKINCOVER' and payment_status in ('PAID', 'REFUNDED')
|
||||
)
|
||||
select
|
||||
),
|
||||
pre_feature_flag_verification_requests as (
|
||||
select
|
||||
vr.id_verification_request,
|
||||
vr.uuid_verification_request,
|
||||
vr.id_verification_set,
|
||||
|
|
@ -35,7 +36,8 @@ select
|
|||
b.id_accommodation,
|
||||
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,
|
||||
(
|
||||
p.total_amount_in_txn_currency is not null
|
||||
|
|
@ -44,7 +46,8 @@ select
|
|||
) 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 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,
|
||||
vr.verification_url,
|
||||
vr.callback_url,
|
||||
|
|
@ -95,17 +98,24 @@ select
|
|||
ccp.checkin_cover_limit_amount_local_curr
|
||||
* (p.total_amount_in_gbp / p.total_amount_in_txn_currency)
|
||||
)::numeric(18, 4) as checkin_cover_limit_amount_in_gbp
|
||||
from int_core__verification_requests vr
|
||||
left join int_core__bookings b on vr.id_verification_request = b.id_verification_request
|
||||
left join
|
||||
from int_core__verification_requests vr
|
||||
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
|
||||
on vr.id_verification_set = vstvt.id_verification_set
|
||||
left join
|
||||
check_in_cover_payments p on vr.id_verification_request = p.id_verification_request
|
||||
left join
|
||||
int_core__check_in_cover_prices ccp on p.currency = ccp.local_currency_iso_4217
|
||||
left join int_core__unified_user gu on gu.id_user = vr.id_user_guest
|
||||
-- 15 is Check-in cover.
|
||||
-- Adding this condition results in only keeping guest journeys that offered the
|
||||
-- check-in cover
|
||||
where vstvt.id_verification_type = 15
|
||||
left join
|
||||
check_in_cover_payments p
|
||||
on vr.id_verification_request = p.id_verification_request
|
||||
left join
|
||||
int_core__check_in_cover_prices ccp
|
||||
on p.currency = ccp.local_currency_iso_4217
|
||||
left join int_core__unified_user gu on gu.id_user = vr.id_user_guest
|
||||
-- 15 is Check-in cover.
|
||||
-- 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