wip
This commit is contained in:
parent
cea7cdb34d
commit
cf024f7b71
3 changed files with 20 additions and 19 deletions
|
|
@ -1,25 +1,22 @@
|
||||||
with
|
with
|
||||||
monthly_new_deals as (
|
int_kpis__agg_daily_deals as (
|
||||||
select
|
select date, dimension_value as hubspot_listing_segmentation, new_deals
|
||||||
date_trunc('MONTH', effective_deal_start_date_utc)::date as start_month,
|
from {{ ref("int_kpis__agg_daily_deals") }}
|
||||||
hubspot_listing_segmentation,
|
where dimension = 'by_number_of_listings'
|
||||||
count(id_deal) as number_of_new_deals
|
|
||||||
from {{ ref("int_kpis__dimension_deals") }}
|
|
||||||
group by 1, 2
|
|
||||||
),
|
),
|
||||||
onboarding_mrr_metrics as (
|
onboarding_mrr_metrics as (
|
||||||
select
|
select
|
||||||
mom.date,
|
mom.date,
|
||||||
'by_number_of_listings' as dimension,
|
'by_number_of_listings' as dimension,
|
||||||
mom.hubspot_listing_segmentation as dimension_value,
|
mom.hubspot_listing_segmentation as dimension_value,
|
||||||
mnd.number_of_new_deals,
|
ad.number_of_new_deals,
|
||||||
mom.expected_mrr as expected_mrr_per_deal,
|
mom.expected_mrr as expected_mrr_per_deal,
|
||||||
mom.expected_mrr * mnd.number_of_new_deals as expected_mrr
|
mom.expected_mrr * ad.number_of_new_deals as expected_mrr
|
||||||
from {{ ref("int_monthly_onboarding_mrr_metrics") }} mom
|
from {{ ref("int_monthly_onboarding_mrr_metrics") }} mom
|
||||||
left join
|
left join
|
||||||
monthly_new_deals mnd
|
int_kpis__agg_daily_deals ad
|
||||||
on date_trunc('MONTH', mom.date)::date = mnd.start_month
|
on mom.date = ad.date
|
||||||
and mom.hubspot_listing_segmentation = mnd.hubspot_listing_segmentation
|
and mom.hubspot_listing_segmentation = ad.hubspot_listing_segmentation
|
||||||
where
|
where
|
||||||
mom.main_billing_country_iso_3 = 'global'
|
mom.main_billing_country_iso_3 = 'global'
|
||||||
and mom.hubspot_listing_segmentation <> 'global'
|
and mom.hubspot_listing_segmentation <> 'global'
|
||||||
|
|
|
||||||
|
|
@ -28,14 +28,15 @@ with
|
||||||
booked_days_per_deal as (
|
booked_days_per_deal as (
|
||||||
select
|
select
|
||||||
icuh.id_deal,
|
icuh.id_deal,
|
||||||
icb.created_date_utc,
|
hd.live_date_utc as created_date_utc,
|
||||||
lag(icb.created_date_utc, 1) over (
|
lag(hd.live_date_utc, 1) over (
|
||||||
partition by icuh.id_deal order by icb.created_date_utc asc
|
partition by icuh.id_deal order by hd.live_date_utc asc
|
||||||
) as previous_booked_date
|
) as previous_booked_date
|
||||||
from int_core__bookings icb
|
from int_core__bookings icb
|
||||||
inner join int_core__user_host icuh on icb.id_user_host = icuh.id_user_host
|
inner join int_core__user_host icuh on icb.id_user_host = icuh.id_user_host
|
||||||
|
inner join int_hubspot__deal hd on icuh.id_deal = hd.id_deal
|
||||||
where icuh.id_deal is not null
|
where icuh.id_deal is not null
|
||||||
group by icuh.id_deal, icb.created_date_utc
|
group by icuh.id_deal, hd.live_date_utc
|
||||||
),
|
),
|
||||||
deal_historic_booking_dates as (
|
deal_historic_booking_dates as (
|
||||||
select
|
select
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,11 @@ select
|
||||||
coalesce(
|
coalesce(
|
||||||
icd.main_billing_country_iso_3_per_deal, 'UNSET'
|
icd.main_billing_country_iso_3_per_deal, 'UNSET'
|
||||||
) as main_billing_country_iso_3_per_deal,
|
) as main_billing_country_iso_3_per_deal,
|
||||||
coalesce(
|
case
|
||||||
icmas.active_accommodations_per_deal_segmentation, 'UNSET'
|
when ldl.deal_lifecycle_state = '01-New'
|
||||||
) as active_accommodations_per_deal_segmentation,
|
then coalesce(dd.hubspot_listing_segmentation, 'UNSET')
|
||||||
|
else coalesce(icmas.active_accommodations_per_deal_segmentation, 'UNSET')
|
||||||
|
end as active_accommodations_per_deal_segmentation,
|
||||||
-- Metrics --
|
-- Metrics --
|
||||||
count(
|
count(
|
||||||
distinct case
|
distinct case
|
||||||
|
|
@ -66,6 +68,7 @@ select
|
||||||
) as deals_booked_in_12_months
|
) as deals_booked_in_12_months
|
||||||
from {{ ref("int_kpis__lifecycle_daily_deal") }} as ldl
|
from {{ ref("int_kpis__lifecycle_daily_deal") }} as ldl
|
||||||
left join {{ ref("int_core__deal") }} as icd on ldl.id_deal = icd.id_deal
|
left join {{ ref("int_core__deal") }} as icd on ldl.id_deal = icd.id_deal
|
||||||
|
left join {{ ref("int_kpis__dimension_deals") }} as dd on ldl.id_deal = dd.id_deal
|
||||||
left join
|
left join
|
||||||
{{ ref("int_kpis__dimension_daily_accommodation") }} as icmas
|
{{ ref("int_kpis__dimension_daily_accommodation") }} as icmas
|
||||||
on ldl.id_deal = icmas.id_deal
|
on ldl.id_deal = icmas.id_deal
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue