-
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.
- Loading branch information
1 parent
509daca
commit 06787e0
Showing
4 changed files
with
101 additions
and
43 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
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
WITH tracts AS ( | ||
SELECT * FROM {{ ref("int__tracts") }} | ||
), | ||
|
||
boros AS ( | ||
SELECT | ||
borough_name, | ||
sum(total_floor_area) AS total_floor_area, | ||
sum(residential_floor_area) AS residential_floor_area, | ||
sum(total_population) AS total_population, | ||
sum(low_mod_income_population) AS low_mod_income_population | ||
FROM tracts | ||
GROUP BY borough_name | ||
), | ||
|
||
boro_calculation AS ( | ||
SELECT | ||
*, | ||
(residential_floor_area / total_floor_area) * 100 AS residential_floor_area_percentage, | ||
(low_mod_income_population / total_population) * 100 AS low_mod_income_population_percentage | ||
FROM boros | ||
) | ||
|
||
SELECT * FROM boro_calculation |
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
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
WITH boros AS ( | ||
SELECT * FROM {{ ref("int__boros") }} | ||
), | ||
|
||
eligibility_calculation AS ( | ||
SELECT | ||
*, | ||
low_mod_income_population_percentage > 51 AND residential_floor_area_percentage > 50 AS eligibility_flag | ||
FROM boros | ||
), | ||
|
||
eligibility AS ( | ||
SELECT | ||
*, | ||
CASE | ||
WHEN eligibility_flag THEN 'CD Eligible' | ||
ELSE 'Ineligible' | ||
END AS eligibility | ||
FROM eligibility_calculation | ||
) | ||
|
||
SELECT * FROM eligibility |