Suppose you have a vector layer in your GRASS GIS database and you want to find all duplicate values in one of the columns of the attribute table of that layer?
SELECT value, COUNT(value) AS dbl FROM sp1th GROUP BY value HAVING (COUNT(value) > 1)
The results shows you for each duplicate value how many times it is found in your table. If you want to select all the records that are double instead of the counts, you can use:
SELECT * FROM sp1th WHERE value IN ( SELECT value FROM sp1th GROUP BY value HAVING (COUNT(value ) > 1) )
You can do this in your favorite SQLite or PostgreSQL manager. Alternatively, you can run this in GRASS GIS using the v.db.select function:
v.db.select -c map=sp1th@ConsStat layer=1 columns=cat where='cat IN ( SELECT cat FROM sp1th GROUP BY cat HAVING (COUNT(cat) > 1))'
Or, if you want to get all the points with duplicate values in the attribute value as a new point layer:
v.extract input=sp1th@ConsStat layer=1 where='value IN (SELECT value FROM sp1th GROUP BY value HAVING(COUNT(value)>1))' output=test
With thanks to this blog from which I got most of this.