Skip to content

Commit

Permalink
Build an intermediate view with station counts per county in 2023, ad…
Browse files Browse the repository at this point in the history
…ded to _models.yml.
  • Loading branch information
zwu2024 committed Feb 16, 2024
1 parent 53357a4 commit 220c9bf
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
10 changes: 10 additions & 0 deletions transform/models/_models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,13 @@ models:
tests:
- not_null
- unique
- name: int_pems__stations_per_county_counted
description: intermediate model with 2023 station count by county
columns:
- name: County
description: county id
- name: stat_counts
description: number of stations in this county
tests:
- not_null
- unique
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

0 comments on commit 220c9bf

Please sign in to comment.