This commit is contained in:
Joaquin Ossa 2025-01-28 16:47:44 +01:00
parent cea7cdb34d
commit cf024f7b71
3 changed files with 20 additions and 19 deletions

View file

@ -28,14 +28,15 @@ with
booked_days_per_deal as (
select
icuh.id_deal,
icb.created_date_utc,
lag(icb.created_date_utc, 1) over (
partition by icuh.id_deal order by icb.created_date_utc asc
hd.live_date_utc as created_date_utc,
lag(hd.live_date_utc, 1) over (
partition by icuh.id_deal order by hd.live_date_utc asc
) as previous_booked_date
from int_core__bookings icb
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
group by icuh.id_deal, icb.created_date_utc
group by icuh.id_deal, hd.live_date_utc
),
deal_historic_booking_dates as (
select