Weekly dimension
This commit is contained in:
parent
c21b05f9cf
commit
c29a47240f
2 changed files with 46 additions and 1 deletions
|
|
@ -8,16 +8,20 @@ with
|
|||
select
|
||||
id.year_number as year,
|
||||
id.month_of_year as month,
|
||||
id.week_of_year as week,
|
||||
id.day_of_month as day,
|
||||
id.date_day as date,
|
||||
id.month_start_date as first_day_month,
|
||||
id.month_end_date as last_day_month,
|
||||
id.week_start_date as first_day_week,
|
||||
id.week_end_date as last_day_week,
|
||||
now()::date as today
|
||||
from int_dates id
|
||||
)
|
||||
select distinct
|
||||
rd.year,
|
||||
rd.month,
|
||||
rd.week,
|
||||
rd.day,
|
||||
rd.date,
|
||||
rd.first_day_month,
|
||||
|
|
@ -37,7 +41,15 @@ select distinct
|
|||
and rd.day < extract(day from rd.today)
|
||||
then true
|
||||
else false
|
||||
end as is_month_to_date
|
||||
end as is_month_to_date,
|
||||
rd.first_day_week,
|
||||
rd.last_day_week,
|
||||
case when rd.date = rd.last_day_week then true else false end as is_end_of_week,
|
||||
case
|
||||
when date_trunc('week', rd.date) = date_trunc('week', rd.today)
|
||||
then true
|
||||
else false
|
||||
end as is_current_week
|
||||
from raw_dates rd
|
||||
where
|
||||
-- include only up-to yesterday
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue