[GIS] Grouping and counting attribute data in QGIS

aggregationattribute-tablecountfields-attributesqgis

I want to group and count features with the same code attribute value.

I can classify the data and enable feature count in the layer list but I cannot get counts in the attribute table.

Best Answer

With a "Virtual Layer" through Layer > Add Layer > Add/Edit Virtual Layer.... you can now use SQL on any layer in QGIS, for example the airport shapefile from the QGIS sample data:

enter image description here

To count the number of airports by USE type and compute the average elevation use:

enter image description here

The results are loaded as a new layer:

enter image description here

Related Question