How do I add the values of a column and then insert it in different table column? e.g. I have a
layer1 with attributes as follow:
and layer2 with attributes:
I am trying to sum the MIN with the same ids at layer1 then insert the result in layer2.
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.
Sign up to join this communityThere is no GIS-specific aspect to your question, however, if you are using a database like PostGIS with your QGIS you can do the following: (I haven't actually checked if the syntax is correct):
WITH temp AS (
SELECT the_branch, SUM(min) as min_sum
FROM layer1
GROUP BY the_branch)
UPDATE layer2
SET layer2.total_min=temp.min_sum
FROM temp
WHERE layer1.branch=temp.the_branch;