commit wip
This commit is contained in:
parent
9f580867c0
commit
089a1c37bd
1 changed files with 25 additions and 0 deletions
25
models/intermediate/cross/int_monthly_churned_deals.sql
Normal file
25
models/intermediate/cross/int_monthly_churned_deals.sql
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
with
|
||||||
|
stg_hubspot__deals as (select * from {{ ref("stg_hubspot__deals") }}),
|
||||||
|
int_monthly_aggregated_metrics_history_by_deal_by_time_window as (
|
||||||
|
select *
|
||||||
|
from {{ ref("int_monthly_aggregated_metrics_history_by_deal_by_time_window") }}
|
||||||
|
),
|
||||||
|
int_core__user_host as (select * from {{ ref("int_core__user_host") }}),
|
||||||
|
int_core__accommodation as (select * from {{ ref("int_core__accommodation") }})
|
||||||
|
select
|
||||||
|
d.id_deal,
|
||||||
|
m.main_deal_name,
|
||||||
|
m.client_type,
|
||||||
|
m.has_active_pms,
|
||||||
|
m.active_pms_list,
|
||||||
|
|
||||||
|
d.cancellation_date_utc,
|
||||||
|
date_trunc('month', d.cancellation_date_utc) as churn_month,
|
||||||
|
from stg_hubspot__deals d
|
||||||
|
left join
|
||||||
|
int_monthly_aggregated_metrics_history_by_deal_by_time_window m
|
||||||
|
on d.id_deal = m.id_deal
|
||||||
|
and date_trunc('month', d.cancellation_date_utc) = date_trunc('month', m.date)
|
||||||
|
left join int_core__user_host uh on d.id_deal = uh.id_deal
|
||||||
|
left join int_core__accommodation a on uh.id_user_host = a.id_user_host
|
||||||
|
where d.cancellation_date_utc is not null
|
||||||
Loading…
Add table
Add a link
Reference in a new issue