fixed int_monthly_growth_score_by_deal
This commit is contained in:
parent
5bcfd7cb9c
commit
abd4a4e8f2
1 changed files with 29 additions and 29 deletions
|
|
@ -71,7 +71,7 @@ with
|
||||||
coalesce(sum(previous_twelve_months.revenue_in_gbp), 0), 0
|
coalesce(sum(previous_twelve_months.revenue_in_gbp), 0), 0
|
||||||
) as effective_deal_revenue_12_months_window
|
) as effective_deal_revenue_12_months_window
|
||||||
from deal_history_from_previous_months as given_month
|
from deal_history_from_previous_months as given_month
|
||||||
-- Retrieve agg data from same deal from the previous twelve
|
-- Retrieve aggregated data from same deal from the previous twelve
|
||||||
-- months
|
-- months
|
||||||
left join
|
left join
|
||||||
deal_history_from_previous_months as previous_twelve_months
|
deal_history_from_previous_months as previous_twelve_months
|
||||||
|
|
@ -81,7 +81,7 @@ with
|
||||||
and given_month.first_day_month
|
and given_month.first_day_month
|
||||||
>= previous_twelve_months.first_day_month + interval '1 months'
|
>= previous_twelve_months.first_day_month + interval '1 months'
|
||||||
group by 1, 2
|
group by 1, 2
|
||||||
) as agg_revenue_data_before_partition
|
) as aggregated_revenue_data_before_partition
|
||||||
),
|
),
|
||||||
metrics_attribution_to_given_month_per_deal as (
|
metrics_attribution_to_given_month_per_deal as (
|
||||||
select
|
select
|
||||||
|
|
@ -100,10 +100,10 @@ with
|
||||||
previous_2_month.first_day_month as previous_2_month_first_day_month,
|
previous_2_month.first_day_month as previous_2_month_first_day_month,
|
||||||
previous_12_month.first_day_month as previous_12_month_first_day_month,
|
previous_12_month.first_day_month as previous_12_month_first_day_month,
|
||||||
previous_13_month.first_day_month as previous_13_month_first_day_month,
|
previous_13_month.first_day_month as previous_13_month_first_day_month,
|
||||||
agg_12m_window.from_first_day_month
|
aggregated_12m_window.from_first_day_month
|
||||||
as agg_revenue_from_first_day_month,
|
as aggregated_revenue_from_first_day_month,
|
||||||
agg_12m_window.to_first_day_month
|
aggregated_12m_window.to_first_day_month
|
||||||
as agg_revenue_to_first_day_month,
|
as aggregated_revenue_to_first_day_month,
|
||||||
|
|
||||||
-- Revenue --
|
-- Revenue --
|
||||||
given_month.revenue_in_gbp as given_month_revenue_in_gbp,
|
given_month.revenue_in_gbp as given_month_revenue_in_gbp,
|
||||||
|
|
@ -154,54 +154,54 @@ with
|
||||||
|
|
||||||
-- 12 Months Window (Account Size) --
|
-- 12 Months Window (Account Size) --
|
||||||
-- Bookings --
|
-- Bookings --
|
||||||
agg_12m_window.deal_created_bookings_12_months_window,
|
aggregated_12m_window.deal_created_bookings_12_months_window,
|
||||||
agg_12m_window.global_created_bookings_12_months_window,
|
aggregated_12m_window.global_created_bookings_12_months_window,
|
||||||
coalesce(
|
coalesce(
|
||||||
cast(
|
cast(
|
||||||
agg_12m_window.deal_created_bookings_12_months_window
|
aggregated_12m_window.deal_created_bookings_12_months_window
|
||||||
as decimal
|
as decimal
|
||||||
) / nullif(
|
) / nullif(
|
||||||
agg_12m_window.global_created_bookings_12_months_window, 0
|
aggregated_12m_window.global_created_bookings_12_months_window, 0
|
||||||
),
|
),
|
||||||
0
|
0
|
||||||
) as deal_contribution_share_to_global_created_bookings,
|
) as deal_contribution_share_to_global_created_bookings,
|
||||||
agg_12m_window.deal_contribution_rank_to_global_created_bookings,
|
aggregated_12m_window.deal_contribution_rank_to_global_created_bookings,
|
||||||
|
|
||||||
-- Listings --
|
-- Listings --
|
||||||
round(
|
round(
|
||||||
agg_12m_window.deal_avg_listings_booked_in_month_12_months_window,
|
aggregated_12m_window.deal_avg_listings_booked_in_month_12_months_window,
|
||||||
2
|
2
|
||||||
) as deal_avg_listings_booked_in_month_12_months_window,
|
) as deal_avg_listings_booked_in_month_12_months_window,
|
||||||
round(
|
round(
|
||||||
agg_12m_window.global_avg_listings_booked_in_month_12_months_window,
|
aggregated_12m_window.global_avg_listings_booked_in_month_12_months_window,
|
||||||
2
|
2
|
||||||
) as global_avg_listings_booked_in_month_12_months_window,
|
) as global_avg_listings_booked_in_month_12_months_window,
|
||||||
coalesce(
|
coalesce(
|
||||||
cast(
|
cast(
|
||||||
agg_12m_window.deal_avg_listings_booked_in_month_12_months_window
|
aggregated_12m_window.deal_avg_listings_booked_in_month_12_months_window
|
||||||
as decimal
|
as decimal
|
||||||
) / nullif(
|
) / nullif(
|
||||||
agg_12m_window.global_avg_listings_booked_in_month_12_months_window,
|
aggregated_12m_window.global_avg_listings_booked_in_month_12_months_window,
|
||||||
0
|
0
|
||||||
),
|
),
|
||||||
0
|
0
|
||||||
) as deal_contribution_share_to_global_avg_listings_booked_in_month,
|
) as deal_contribution_share_to_global_avg_listings_booked_in_month,
|
||||||
agg_12m_window.deal_contribution_rank_to_global_avg_listings_booked_in_month,
|
aggregated_12m_window.deal_contribution_rank_to_global_avg_listings_booked_in_month,
|
||||||
|
|
||||||
-- Revenue --
|
-- Revenue --
|
||||||
agg_12m_window.deal_revenue_12_months_window,
|
aggregated_12m_window.deal_revenue_12_months_window,
|
||||||
agg_12m_window.effective_deal_revenue_12_months_window,
|
aggregated_12m_window.effective_deal_revenue_12_months_window,
|
||||||
agg_12m_window.effective_global_revenue_12_months_window,
|
aggregated_12m_window.effective_global_revenue_12_months_window,
|
||||||
coalesce(
|
coalesce(
|
||||||
cast(
|
cast(
|
||||||
agg_12m_window.effective_deal_revenue_12_months_window
|
aggregated_12m_window.effective_deal_revenue_12_months_window
|
||||||
as decimal
|
as decimal
|
||||||
) / nullif(
|
) / nullif(
|
||||||
agg_12m_window.effective_global_revenue_12_months_window, 0
|
aggregated_12m_window.effective_global_revenue_12_months_window, 0
|
||||||
),
|
),
|
||||||
0
|
0
|
||||||
) as deal_contribution_share_to_global_revenue,
|
) as deal_contribution_share_to_global_revenue,
|
||||||
agg_12m_window.deal_contribution_rank_to_global_revenue
|
aggregated_12m_window.deal_contribution_rank_to_global_revenue
|
||||||
|
|
||||||
from deal_history_from_previous_months as given_month
|
from deal_history_from_previous_months as given_month
|
||||||
-- Retrieve monthly data from same deal and previous month
|
-- Retrieve monthly data from same deal and previous month
|
||||||
|
|
@ -232,9 +232,9 @@ with
|
||||||
and previous_13_month.id_deal = given_month.id_deal
|
and previous_13_month.id_deal = given_month.id_deal
|
||||||
-- Retrieve aggregation over 12 previous months
|
-- Retrieve aggregation over 12 previous months
|
||||||
left join
|
left join
|
||||||
revenue_12_months_window_aggregation_per_deal agg_12m_window
|
revenue_12_months_window_aggregation_per_deal aggregated_12m_window
|
||||||
on agg_12m_window.id_deal = given_month.id_deal
|
on aggregated_12m_window.id_deal = given_month.id_deal
|
||||||
and agg_12m_window.first_day_month = given_month.first_day_month
|
and aggregated_12m_window.first_day_month = given_month.first_day_month
|
||||||
),
|
),
|
||||||
growth_score_computation as (
|
growth_score_computation as (
|
||||||
select
|
select
|
||||||
|
|
@ -250,8 +250,8 @@ with
|
||||||
m.previous_2_month_first_day_month,
|
m.previous_2_month_first_day_month,
|
||||||
m.previous_12_month_first_day_month,
|
m.previous_12_month_first_day_month,
|
||||||
m.previous_13_month_first_day_month,
|
m.previous_13_month_first_day_month,
|
||||||
m.agg_revenue_from_first_day_month,
|
m.aggregated_revenue_from_first_day_month,
|
||||||
m.agg_revenue_to_first_day_month,
|
m.aggregated_revenue_to_first_day_month,
|
||||||
|
|
||||||
m.given_month_revenue_in_gbp,
|
m.given_month_revenue_in_gbp,
|
||||||
m.previous_1_month_revenue_in_gbp,
|
m.previous_1_month_revenue_in_gbp,
|
||||||
|
|
@ -358,8 +358,8 @@ select
|
||||||
gsc.previous_2_month_first_day_month,
|
gsc.previous_2_month_first_day_month,
|
||||||
gsc.previous_12_month_first_day_month,
|
gsc.previous_12_month_first_day_month,
|
||||||
gsc.previous_13_month_first_day_month,
|
gsc.previous_13_month_first_day_month,
|
||||||
gsc.agg_revenue_from_first_day_month,
|
gsc.aggregated_revenue_from_first_day_month,
|
||||||
gsc.agg_revenue_to_first_day_month,
|
gsc.aggregated_revenue_to_first_day_month,
|
||||||
|
|
||||||
gsc.given_month_revenue_in_gbp,
|
gsc.given_month_revenue_in_gbp,
|
||||||
gsc.previous_1_month_revenue_in_gbp,
|
gsc.previous_1_month_revenue_in_gbp,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue