I have the following query:
SELECT ?admin ?name ?abbr
WHERE {
VALUES ?admin { wd:Q771 }
?admin wdt:P131 ?country;
wdt:P17 ?country.
OPTIONAL { ?admin wdt:P1813 ?alias. }
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en".
?admin rdfs:label ?name.
?alias rdfs:label ?abbr.
}
}
This retrieves the administration in VALUES
with its English name and abbrevations, if available. For example:
admin | name | abbr |
---|---|---|
wd:Q771 | Massachusetts | MA |
wd:Q771 | Massachusetts | Mass. |
Now I would like to filter it such that only the shortest abbreviation is displayed. For the above output, for example, I would only get one record, the one with MA
. How can I accomplish this?