This repository has been archived by the owner on Jul 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Refactor scratch pad #283
Comments
SELECT
pts.prime_bbl,
coalesce(cama.residarea, pts.residarea) as residarea,
coalesce(cama.officearea, pts.officearea) as officearea,
coalesce(cama.retailarea, pts.retailarea) as retailarea,
coalesce(cama.garagearea, pts.garagearea) as garagearea,
coalesce(cama.storagearea, pts.storagearea) as storagearea,
coalesce(cama.factoryarea, pts.factoryarea) as factoryarea,
coalesce(cama.otherarea, pts.otherarea) as otherarea,
coalesce(cama.commercialarea, pts.commercialarea) as commercialarea
FROM (
SELECT
coalesce(
coalesce(dof_condo.condo_bill,dof_condo.condo_base),
LEFT(parid,10)
) as prime_bbl,
NULLIF(SUM(
office_area_gross::numeric+
retail_area_gross::numeric+
garage_area::numeric+
storage_area_gross::numeric+
factory_area_gross::numeric+
other_area_gross::numeric
), 0) as commercialarea,
NULLIF(SUM(residential_area_gross::numeric), 0) as residarea,
NULLIF(SUM(office_area_gross::numeric), 0) as officearea,
NULLIF(SUM(retail_area_gross::numeric), 0) as retailarea,
NULLIF(SUM(garage_area::numeric), 0) as garagearea,
NULLIF(SUM(storage_area_gross::numeric), 0) as storagearea,
NULLIF(SUM(factory_area_gross::numeric), 0) as factoryarea,
NULLIF(SUM(other_area_gross::numeric), 0) as otherarea
FROM pluto_pts LEFT JOIN dof_condo
ON appt_boro||appt_block||appt_lot = dof_condo.condo_base
WHERE RIGHT(LEFT(parid,10), 2) not like '75'
GROUP BY prime_bbl
) pts LEFT JOIN (
SELECT
COALESCE(
coalesce(dof_condo.condo_bill,dof_condo.condo_base),
cama.bbl
) as prime_bbl,
NULLIF(SUM(commercialarea::numeric), 0) as commercialarea,
NULLIF(SUM(residarea::numeric), 0) as residarea,
NULLIF(SUM(officearea::numeric), 0) as officearea,
NULLIF(SUM(retailarea::numeric), 0) as retailarea,
NULLIF(SUM(garagearea::numeric), 0) as garagearea,
NULLIF(SUM(storagearea::numeric), 0) as storagearea,
NULLIF(SUM(factoryarea::numeric), 0) as factoryarea,
NULLIF(SUM(otherarea::numeric), 0) as otherarea
FROM (
SELECT * FROM pluto_input_cama_dof
WHERE bldgnum = '1' AND LENGTH(bbl) = 10
) cama LEFT JOIN dof_condo
ON cama.bbl = dof_condo.condo_base
GROUP BY prime_bbl
) cama on pts.prime_bbl = cama.prime_bbl; |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
This issue will be used as a scratch pad to document potential refactors
Terminologies:
bbl
(the actual bbl)billing_bbl
(the actual bbl for non-condo lots, 75 condo bbl for condo lots)prime_bbl
(the same as billing bbl, this is the intended join key for all DOF related tables)cama_bsmtcode.sql
replacing
create_cama_primebbl.sql
andcama_bsmttype.sql
The text was updated successfully, but these errors were encountered: