I would like to filter a layer with the maximum value of field_a, grouped by field_b. I tried this expression: "field_a"= maximum ( "field_a","field_b")
But it doesn't work (there are no more features in the layer). When I use this expression for Select by Expression, the features are selected. Is there a way to filter them (without selecting)?
[Edit] I want to filter a existing layer (right mouse click -> filter). I don't want to select features or to create a new layer.
Answer
The filter query (layer properties/source/provider feature filter
) allows you to specify an SQL where
clause. If you enter id=1
it will translate it to select * from mylayer where id=1
.
From there, you can add a sub-query in this where
clause to identify the IDs (or else) of interest:
field_a IN (SELECT MAX(field_a) FROM myLayer GROUP BY field_b)
No comments:
Post a Comment