data-dwh-dbt-project/models/reporting/general/new_dash_booking_summary.sql

42 lines
2.1 KiB
MySQL
Raw Normal View History

with
int_core__booking_summary as (select * from {{ ref("int_core__booking_summary") }}),
int_core__deal as (select * from {{ ref("int_core__deal") }}),
int_hubspot__deal as (select * from {{ ref("int_hubspot__deal") }})
select
b.id_booking as id_booking,
2025-02-19 16:00:33 +01:00
b.has_verification_request as has_verification_request,
b.id_deal as id_deal,
d.main_deal_name as main_deal_name,
hd.deal_name as hubspot_deal_name,
d.main_billing_country_iso_3_per_deal as main_billing_country,
hd.account_manager as account_manager,
b.booking_status as booking_status,
b.program_name as program_name,
b.booking_created_date_utc as booking_created_date_utc,
b.booking_check_in_date_utc as booking_check_in_date_utc,
b.booking_check_out_date_utc as booking_check_out_date_utc,
b.booking_number_of_nights as booking_number_of_nights,
b.host_currency_code as host_currency_code,
b.new_dash_version as new_dash_version,
date(b.user_in_new_dash_since_timestamp_at_utc) as user_in_new_dash_since_date_utc,
b.booking_total_price_in_gbp as booking_total_price_in_gbp,
b.service_first_chargeable_date_utc as service_first_chargeable_date_utc,
b.service_last_chargeable_date_utc as service_last_chargeable_date_utc,
b.number_of_applied_services as number_of_applied_services,
b.number_of_applied_upgraded_services as number_of_applied_upgraded_services,
b.is_booking_chargeable as is_booking_chargeable,
b.is_booking_cancelled as is_booking_cancelled,
b.has_upgraded_services as has_upgraded_services,
b.has_screening_service_business_type as has_screening_service_business_type,
2025-04-08 12:09:08 +02:00
b.has_upgraded_screening_service_business_type
as has_upgraded_screening_service_business_type,
b.has_deposit_management_service_business_type
as has_deposit_management_service_business_type,
b.has_protection_service_business_type as has_protection_service_business_type
from int_core__booking_summary b
left join int_core__deal d on b.id_deal = d.id_deal
left join int_hubspot__deal hd on b.id_deal = hd.id_deal
-- Select only New Dash bookings
where b.is_missing_id_deal = false and b.is_user_in_new_dash = true