-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build an intermediate view with station counts per county in 2023, ad…
…ded to _models.yml.
- Loading branch information
Showing
2 changed files
with
33 additions
and
2 deletions.
There are no files selected for viewing
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
25 changes: 23 additions & 2 deletions
25
transform/models/intermediate/int_pems__stations_per_county_counted.sql
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,24 @@ | ||
with | ||
|
||
source as ( | ||
select * from {{ ref("stg_pems__station_meta") }} | ||
), | ||
|
||
county_data as ( | ||
select | ||
county, | ||
Count(id) as sta_counts | ||
from source | ||
where Year(meta_date) = 2023 | ||
group by county | ||
|
||
) | ||
|
||
select * | ||
from stg_pems__station_meta | ||
limit 10 | ||
from county_data | ||
order by sta_counts desc | ||
|
||
|
||
-- select * | ||
-- from stg_pems__station_meta | ||
-- limit 10 |