I have a vector file "data.shp" containing the following fields:
ID, value1, AREA
I want to add a new column "value2" and set it as value1/AREA. Since I want to do that for many columns and files I want to use SQL.
I tried with virtual layer in QGIS with no success. I wrote in the query the following :
ALTER TABLE data
ADD value2 float;
UPDATE data
SET value2 = value1/AREA
Are alter and update commands working with virtual layer? Is there any other way?
SELECT col1, col2 [AS col_name] [, FUNC(col3) AS other_col_name], geometry, ... FROM <shapefile_name> [WHERE ...];
in the Virtual Layer SQL dialog (or DB Manager).