38 lines
854 B
MySQL
38 lines
854 B
MySQL
|
|
|
||
|
|
{{ config(materialized="table", unique_key=["date", "dimension", "dimension_value"]) }}
|
||
|
|
|
||
|
|
with
|
||
|
|
int_core__mtd_accommodation_segmentation as (
|
||
|
|
select * from {{ ref("int_core__mtd_accommodation_segmentation") }}
|
||
|
|
),
|
||
|
|
int_dates_mtd as (select * from {{ ref("int_dates_mtd") }})
|
||
|
|
|
||
|
|
select distinct
|
||
|
|
d.year,
|
||
|
|
d.month,
|
||
|
|
d.day,
|
||
|
|
d.date,
|
||
|
|
'global' as dimension,
|
||
|
|
'global' as dimension_value,
|
||
|
|
d.first_day_month,
|
||
|
|
d.last_day_month,
|
||
|
|
d.is_end_of_month,
|
||
|
|
d.is_current_month
|
||
|
|
from int_dates_mtd d
|
||
|
|
|
||
|
|
union all
|
||
|
|
|
||
|
|
select distinct
|
||
|
|
d.year,
|
||
|
|
d.month,
|
||
|
|
d.day,
|
||
|
|
d.date,
|
||
|
|
'by_number_of_listings' as dimension,
|
||
|
|
a.active_accommodations_per_deal_segmentation as dimension_value,
|
||
|
|
d.first_day_month,
|
||
|
|
d.last_day_month,
|
||
|
|
d.is_end_of_month,
|
||
|
|
d.is_current_month
|
||
|
|
from int_dates_mtd d
|
||
|
|
inner join int_core__mtd_accommodation_segmentation a
|
||
|
|
on d.date = a.date
|