Last active
February 24, 2020 13:31
-
-
Save robert8138/d243a987bb200d8e3e3477525fcbd700 to your computer and use it in GitHub Desktop.
Fact and Dimension Tables in Actions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
b.dim_market | |
, SUM(a.m_bookings) AS m_bookings | |
FROM ( | |
SELECT | |
id_listing | |
, 1 AS m_bookings | |
, m_a # not used (for illustration only) | |
, m_b # not used (for illustration only) | |
, m_c # not used (for illustration only) | |
FROM | |
fct_bookings | |
WHERE | |
ds BETWEEN '{{ last_sunday }}' AND '{{ this_saturday }}' | |
) a | |
JOIN ( | |
SELECT | |
id_listing | |
, dim_market | |
, dim_x # not used (for illustration only) | |
, dim_y # not used (for illustration only) | |
, dim_z # not used (for illustration only) | |
FROM | |
dim_listings | |
WHERE | |
ds BETWEEN '{{ latest_ds }}' | |
) b | |
ON (a.id_listing = b.id_listing) | |
GROUP BY | |
b.dim_market | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment