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.
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.
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:
To count the number of airports by USE type and compute the average elevation use:
The results are loaded as a new layer:
This was the best result on Google I could find, but the screenshot tutorial by G M is out of date and it took me a while to work out how to use the plugin.
How this helps other people.
QGIS 3.10 comes with a "Statistics by categories" tool in the QGIS's Processing Toolbox (Ctrl+Alt+T).
This is the result:
I suggest you to install Group Stats plugin. Here is a quick tutorial:
The Count will appear. If you go to preferences you should be able to select only Count avoiding the other parameters to be displayed (this is not my case...). Remember before click Save button you have to select the fields you want to add to your .csv: hold on Shift for do that. Here is a more advanced tutorial written by Anita Graser.
you could also use Qspatialite in QGIS. The SQL window is just as Mapinfo one. Up to you after to make your SQL request with a groupby command on the wanted column.