query-898aa1b59f9326a5b3c116d83402f4cb
How to limit result to qualifier with oldest value - searching former municipalities in FinlandHello, has three values for P131 - I'd like the result to only include the oldest one Hitis. (Q817249)BengtskÃĪr . For example (P582)end time and (P580)start time . I don't want any duplicates, but the following query has several duplicates due to the items having been part of multiple former municipalities (?fdkommun) defined by the qualifiers (P131)located in the administrative territorial entity I'd like to get a result with all Wikidata items that are part of a Swedish-speaking municipality in Finland, including the item's region and former municipality defined through I'm only interested in the oldest possible of the former municipalities - how can I make the query not include newer former municipalities?
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel ?instanceofLabel ?fdkommunLabel ?kommunLabel ?landskapLabel
WHERE
{
?item wdt:P131 ?kommun. ?kommun wdt:P31 wd:Q856076. ?kommun wdt:P37 wd:Q9027.
OPTIONAL{?item wdt:P131 ?fdkommun. ?fdkommun wdt:P31 wd:Q17468533.}
OPTIONAL{?kommun wdt:P131 ?landskap. ?landskap wdt:P31 wd:Q193512.}
OPTIONAL{?item wdt:P31 ?instanceof.}
SERVICE wikibase:label { bd:serviceParam wikibase:language "sv,fi,en,de". }
}