I have a table (shapefile) in QGIS where I want to select features that satisfies this condition:
group by a field ("join_label"
) and within the "grouped field"
, pick the attribute with the highest area (the area has already been calculated in a separate field)
I tried to do this:
maximum("Area", group_by:="join_label")
This expression selects everything in the table.
I wanted to use the "Execute SQL" function but how do I write the query?
2 Answers 2
Using the Execute SQL function:
SELECT
join_label,
MAX("Area") as max_area,
geometry
FROM
input1
GROUP BY
join_label
Not forgetting to select the layer in the Additional input datasources
at the top of the tool window (which gets the name input1
in your expression).
Use Select by expression with this expression:
area = maximum(area, group_by:=join_label)
-
it works as well ! Thank you !!AchB– AchB2021年08月31日 15:11:45 +00:00Commented Aug 31, 2021 at 15:11
Explore related questions
See similar questions with these tags.