1

I am looking to do an update query to one table (munparcel_zoning) with the sum of values from a column in another table (permability.permarea) where the type (permtype) is equal to a value (impervious). As this is a many-to-one, I am thinking I need a group by (parcelid). As there are two tables involved I am thinking the best way is to do an inner join, using parcelid = parcelid from each table. However, I am having issues with the query executing.

UPDATE munparcel_zoning
SET imperv = 
(SELECT Sum(permability.permarea)
    FROM permability
WHERE permability.permtype = 'impervious'
GROUP BY permability.parcelid)
INNER JOIN munparcel_zoning
ON permability.parcelid = munparcel_zoning.parcelid;

1 Answer 1

1

what about...

UPDATE munparcel_zoning
SET imperv =
(
SELECT pa.sum_permarea FROM
(
SELECT parcelid, Sum(permarea) As sum_permarea
FROM permability
WHERE permtype = 'impervious'
GROUP BY parcelid
) pa
JOIN munparcel_zoning mz ON(pa.parcelid = mz.parcelid)
);

...does that get you any closer?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.