[Qgis-user] filter on SELECT DISTINCT

Jukka Rahkonen jukka.rahkonen at mmmtike.fi
Sun Dec 1 02:01:51 PST 2013


Matt Boyd <mattslists at ...> writes:

> 
> Hi Group,I've a set of polygons in a sqlite file. Some of the adjacent
polygons have the same name, others don't. I only want to display the name once.
> 
> I'm attempting to do this by copying the layer, then filtering on the
label column.
> 
> "label" in (SELECT DISTINCT label FROM gippsland_oilgas_fields_mga55)
> 
> 
> but, it's not filtering, I can either get all polygons or none. It's
probably a simple thing in my sql I'm missing (it's been a while since I did
this).

Hi,

You select now all distinct label values that exist and then all features
with any of them which means that everything gets selected.

For selecting only one row from each group you can use something like

select max(rowid), key, value 
from labeltest
group by key

I would consider making an extra attribute to the data for selecting which
polygons will be labeled. It could be popolated for example with

update labeltest set label_this='true'
where rowid in
(select max(rowid) as rowid 
from labeltest
group by key)

-Jukka Rahkonen-




More information about the Qgis-user mailing list