Last active
May 30, 2023 14:01
-
-
Save portovep/0adf42124568567bb98e0c7145098f39 to your computer and use it in GitHub Desktop.
Example of a dbt intermediate model
This file contains 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
with | |
height as ( | |
select * from {{ dbt_unit_testing.ref('stg_gym_app__height') }} | |
), | |
weight as ( | |
select * from {{ dbt_unit_testing.ref('stg_gym_app__weight') }} | |
), | |
enrich_with_lasted_height_recorded_before_the_weight_measurement as ( | |
select | |
weight.created_date, | |
user_id, | |
weight, | |
(select height | |
from height | |
where height.created_date < weight.created_date and | |
height.user_id = weight.user_id | |
order by height.created_date DESC | |
limit 1) as height | |
from weight | |
) | |
select * from enrich_with_lasted_height_recorded_before_the_weight_measurement |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment