Skip to content

Commit

Permalink
Modify foreclosure script to work with values of 0
Browse files Browse the repository at this point in the history
* Fix to work with 0

* Update dbt/models/proximity/proximity.cnt_pin_num_foreclosure.sql

Co-authored-by: Jean Cochrane <[email protected]>

* lintr

---------

Co-authored-by: Jean Cochrane <[email protected]>
  • Loading branch information
Damonamajor and jeancochrane authored Feb 7, 2025
1 parent fe8c98b commit 3db4259
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions dbt/models/proximity/proximity.cnt_pin_num_foreclosure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@ SELECT
) AS num_foreclosure_in_half_mile_past_5_years,
COALESCE(pc.num_pin_in_half_mile, 1) AS num_pin_in_half_mile,
ROUND(
CAST(pib.num_foreclosure_in_half_mile_past_5_years AS DOUBLE) / (
CAST(pc.num_pin_in_half_mile AS DOUBLE) / 1000
), 2
CAST(
COALESCE(pib.num_foreclosure_in_half_mile_past_5_years, 0) AS DOUBLE
)
/ (CAST(pc.num_pin_in_half_mile AS DOUBLE) / 1000),
2
) AS num_foreclosure_per_1000_pin_past_5_years,
CONCAT(
CAST(CAST(pl.year AS INT) - 5 AS VARCHAR),
Expand Down

0 comments on commit 3db4259

Please sign in to comment.