query-f58e8030488e40cbd5898fd78e27724b

rq turtle/ttl

Parlamentari e ministri 50-80enni SELECT DISTINCT ?item ?itemLabel (COUNT(DISTINCT ?position_statement) AS ?ministerCount) WHERE { ?item wdt:P31 wd:Q5. ?item wdt:P27 wd:Q38. ?item wdt:P569 ?birth. filter (?birth > "1941-01-01"^^xsd:dateTime). filter (?birth < "1972-01-24"^^xsd:dateTime). MINUS { ?item wdt:P570 ?death. }. # Ex parlamentari ?item wdt:P39/wdt:P361/wdt:P361 wd:Q1117578. MINUS { ?item wdt:P39/wdt:P361/wdt:P361 wd:Q1117578 ; pq:P580 ?start FILTER (?start >= "2018-01-01T00:00:00Z"^^xsd:dateTime) . } # Ministri ?item p:P39 ?position_statement . ?position_statement ps:P39/wdt:P361 wd:Q3687318. # Ma non ministri recenti MINUS { ?item p:P39 ?position_recent . ?position_recent ps:P39/wdt:P361 wd:Q3687318. ?position_recent pq:P582 ?position_end FILTER (?position_end >= "2014-01-01T00:00:00Z"^^xsd:dateTime). } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],it". } } GROUP BY ?item ?itemLabel

Use at

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
# Parlamentari e ministri 50-80enni
SELECT DISTINCT ?item ?itemLabel (COUNT(DISTINCT ?position_statement) AS ?ministerCount)
WHERE 
{
  ?item wdt:P31 wd:Q5.
  ?item wdt:P27 wd:Q38.
  ?item wdt:P569 ?birth.
  filter (?birth > "1941-01-01"^^xsd:dat).
  filter (?birth < "1972-01-24"^^xsd:dat).
  MINUS { ?item wdt:P570 ?death. }.
  # Ex parlamentari
  ?item wdt:P39/wdt:P361/wdt:P361 wd:Q1117578.
  MINUS {  ?item wdt:P39/wdt:P361/wdt:P361 wd:Q1117578 ; 
                 pq:P580 ?start FILTER (?start >= "2018-01-01T00:00:00Z"^^xsd:dateTime) . }
  # Ministri
  ?item p:P39 ?position_statement .
  ?position_statement ps:P39/wdt:P361 wd:Q3687318.
  # Ma non ministri recenti
  MINUS { ?item p:P39 ?position_recent .
         ?position_recent ps:P39/wdt:P361 wd:Q3687318.
         ?position_recent pq:P582 ?position_end
                   FILTER (?position_end >= "2014-01-01T00:00:00Z"^^xsd:dateTime). }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],it". }
}
GROUP BY ?item ?itemLabel

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v1("?birth") v3("?death") v2("?item"):::projected v8("?ministerCount") v6("?position_end") v7("?position_recent") v5("?position_statement"):::projected v4("?start") a1((" ")) a2((" ")) a3((" ")) a4((" ")) a5((" ")) a6((" ")) c16(["wd:Q3687318"]):::iri c6(["wd:Q38"]):::iri c20(["bd:serviceParam"]):::iri c11(["wd:Q1117578"]):::iri c4(["wd:Q5"]):::iri c22(["#91;AUTO_LANGUAGE#93;,it"]):::literal f0[["?birth < s1972-01-24^^<http://www.w3.org/2001/XMLSchema#dat>'"]] f0 --> v1 f1[["?birth > s1941-01-01^^<http://www.w3.org/2001/XMLSchema#dat>'"]] f1 --> v1 v2 --"p:direct/P31"--> c4 v2 --"p:direct/P27"--> c6 v2 --"p:direct/P569"--> v1 subgraph minus2["MINUS"] style minus2 stroke-width:6px,fill:pink,stroke:red; v2 --"p:direct/P570"--> v3 end v2 --"p:direct/P39"--> a1 a1 --"p:direct/P361"--> a2 a2 --"p:direct/P361"--> c11 subgraph minus3["MINUS"] style minus3 stroke-width:6px,fill:pink,stroke:red; f4[["?start >= '2018-01-01T00:00:00Z^^xsd:dateTime'"]] f4 --> v4 v2 --"p:direct/P39"--> a3 a3 --"p:direct/P361"--> a4 a4 --"p:direct/P361"--> c11 v2 --"p:qualifier/P580"--> v4 end v2 --"p:P39"--> v5 v5 --"p:statement/P39"--> a5 a5 --"p:direct/P361"--> c16 subgraph minus5["MINUS"] style minus5 stroke-width:6px,fill:pink,stroke:red; f6[["?position_end >= '2014-01-01T00:00:00Z^^xsd:dateTime'"]] f6 --> v6 v2 --"p:P39"--> v7 v7 --"p:statement/P39"--> a6 a6 --"p:direct/P361"--> c16 v7 --"p:qualifier/P582"--> v6 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c20 --"wikibase:language"--> c22 end bind8[/"count(?position_statement)"/] v5 --o bind8 bind8 --as--o v8