Skip to content

Commit

Permalink
Make view unique by primary keys
Browse files Browse the repository at this point in the history
  • Loading branch information
wrridgeway committed Oct 24, 2024
1 parent 57f6937 commit 6aae155
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions dbt/models/reporting/reporting.vw_pin_school_impact.sql
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,22 @@ WITH ranking AS (
WHERE info.major_type = 'SCHOOL'
),

-- We need to use array_agg for this CTE since some parcels can be in multiple
-- SSAs
tif_ssa AS (
SELECT
pin.pin,
pin.year,
info.agency_name,
info.minor_type
info.minor_type,
ARRAY_AGG(info.agency_name) AS agency_name
FROM {{ source('tax', 'pin') }} AS pin
LEFT JOIN {{ source('tax', 'tax_code') }} AS code
ON pin.tax_code_num = code.tax_code_num
AND pin.year = code.year
INNER JOIN
{{ source('tax', 'agency_info') }} AS info
ON code.agency_num = info.agency_num
GROUP BY pin.pin, pin.year, info.minor_type
)

SELECT
Expand Down

0 comments on commit 6aae155

Please sign in to comment.