Changes in deals lifecycle
This commit is contained in:
parent
e827c0f9d5
commit
525720ea0a
2 changed files with 19 additions and 24 deletions
|
|
@ -158,25 +158,22 @@ select
|
|||
second_to_last_time_booked_date_utc,
|
||||
cancellation_date_utc,
|
||||
case
|
||||
-- 01-New: The deal has been created this month according to the data in
|
||||
-- hubspot.
|
||||
-- 01-New: The deal has been created this month.
|
||||
-- Additionally, the deal has not been offboarded in hubspot.
|
||||
when
|
||||
deal_was_created_this_month
|
||||
and not deal_has_been_offboarded
|
||||
and is_deal_in_hubspot
|
||||
then '01-New'
|
||||
-- 02-Never Booked: The deal is not API, has been created before this month, or
|
||||
-- it doesn't exist in hubspot, and has not had any booking.
|
||||
-- Additionally, the deal has not been offboarded in hubspot.
|
||||
-- 02-Never Booked: The deal is not API, has been created before this month
|
||||
-- and has not had any booking. Additionally, the deal has not been offboarded
|
||||
-- in hubspot.
|
||||
when
|
||||
not deal_has_at_least_one_booking
|
||||
and (
|
||||
not deal_was_created_this_month
|
||||
or (deal_was_created_this_month and not is_deal_in_hubspot)
|
||||
)
|
||||
and not deal_was_created_this_month
|
||||
and not deal_has_been_offboarded
|
||||
and not is_api_deal
|
||||
and is_deal_in_hubspot
|
||||
then '02-Never Booked'
|
||||
-- 04-Active:
|
||||
-- The deal is API, is not New and has not been offboarded
|
||||
|
|
@ -184,22 +181,15 @@ select
|
|||
-- been less than 12 months since the last booking and has not been offboarded
|
||||
when
|
||||
-- API deals --
|
||||
(
|
||||
is_api_deal
|
||||
and (
|
||||
not deal_was_created_this_month
|
||||
or (deal_was_created_this_month and not is_deal_in_hubspot)
|
||||
)
|
||||
and not deal_has_been_offboarded
|
||||
)
|
||||
is_api_deal
|
||||
and not deal_was_created_this_month
|
||||
and not deal_has_been_offboarded
|
||||
and is_deal_in_hubspot
|
||||
-- Platform deals --
|
||||
or (
|
||||
not is_api_deal
|
||||
and deal_has_at_least_one_booking
|
||||
and (
|
||||
not deal_was_created_this_month
|
||||
or (deal_was_created_this_month and not is_deal_in_hubspot)
|
||||
)
|
||||
and not deal_was_created_this_month
|
||||
and has_been_booked_within_last_12_months
|
||||
and not deal_has_been_offboarded
|
||||
-- not reactivated
|
||||
|
|
@ -207,6 +197,7 @@ select
|
|||
had_previous_booking_more_than_12_months_before_the_last
|
||||
and has_been_booked_within_current_month
|
||||
)
|
||||
and is_deal_in_hubspot
|
||||
)
|
||||
then '04-Active'
|
||||
-- 05-Churning: The deal has been offboarded this month.
|
||||
|
|
@ -222,6 +213,7 @@ select
|
|||
and not is_api_deal
|
||||
)
|
||||
or deal_was_offboarded_this_month
|
||||
and is_deal_in_hubspot
|
||||
then '05-Churning'
|
||||
-- 06-Inactive: The deal has been offboarded in the past but not this
|
||||
-- month.
|
||||
|
|
@ -237,6 +229,7 @@ select
|
|||
and not is_api_deal
|
||||
)
|
||||
or (deal_has_been_offboarded and not deal_was_offboarded_this_month)
|
||||
and is_deal_in_hubspot
|
||||
then '06-Inactive'
|
||||
-- 07-Reactivated: The deal is not offboarded but was
|
||||
-- churned/inactive, and
|
||||
|
|
@ -246,8 +239,9 @@ select
|
|||
and has_been_booked_within_current_month
|
||||
and not deal_has_been_offboarded
|
||||
and not is_api_deal
|
||||
and is_deal_in_hubspot
|
||||
then '07-Reactivated'
|
||||
else null
|
||||
else '99-Not in HubSpot'
|
||||
end as deal_lifecycle_state,
|
||||
has_been_booked_within_current_month,
|
||||
has_been_booked_within_last_6_months,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue