query-cd3871d20fa186ca509c3dcb839f6d47

rq turtle/ttl

title: The current prime minister of Iceland (should be 1) SELECT ?currentPrimeMinisters ?currentPrimeMinistersLabel ?startTime WHERE { # Prime minister of Iceland wd:Q19190022 p:P1308 ?statement .

# Get all values of the officeholder statement ?statement ps:P1308 ?currentPrimeMinisters .

# Get the start time (P580) of the officeholder statement ?statement pq:P580 ?startTime .

# Get the label of the prime ministers ?currentPrimeMinisters rdfs:label ?currentPrimeMinistersLabel . FILTER(LANG(?currentPrimeMinistersLabel) = "en") }

Order start time and get 1 value (which is the most recent start date)

ORDER BY DESC(?startTime) LIMIT 1

Use at

PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
#title: The current prime minister of Iceland (should be 1)
SELECT ?currentPrimeMinisters ?currentPrimeMinistersLabel ?startTime WHERE {
  # Prime minister of Iceland
  wd:Q19190022 p:P1308 ?statement .

  # Get all values of the officeholder statement
  ?statement ps:P1308 ?currentPrimeMinisters .

  # Get the start time (P580) of the officeholder statement
  ?statement pq:P580 ?startTime .

  # Get the label of the prime ministers
  ?currentPrimeMinisters rdfs:label ?currentPrimeMinistersLabel .
  FILTER(LANG(?currentPrimeMinistersLabel) = "en")
}
# Order start time and get 1 value (which is the most recent start date)
ORDER BY DESC(?startTime)
LIMIT 1

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?currentPrimeMinisters"):::projected v2("?currentPrimeMinistersLabel"):::projected v1("?startTime"):::projected v3("?statement") c2(["wd:Q19190022"]):::iri f0[["?currentPrimeMinistersLabel = 'en'"]] f0 --> v2 c2 --"p:P1308"--> v3 v3 --"p:statement/P1308"--> v4 v3 --"p:qualifier/P580"--> v1 v4 --"rdfs:label"--> v2