query-78b9950d84b753af6134ba4e86be0602

rq turtle/ttl

members of Massachusetts House of Representatives

SELECT ?item ?itemLabel ?date_of_birth ?image ?electoral_district ?electoral_districtLabel ?start ?end WHERE { SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } ?item p:P39 ?position_statement. ?position_statement ps:P39 wd:Q17342542. ?position_statement wikibase:rank ?rank. FILTER (?rank = wikibase:PreferredRank || ?rank = wikibase:NormalRank && NOT EXISTS { ?item p:P39/wikibase:rank wikibase:PreferredRank. }) OPTIONAL { ?item wdt:P569 ?date_of_birth. } OPTIONAL { ?item wdt:P18 ?image. } OPTIONAL { ?position_statement pq:P768 ?electoral_district. } OPTIONAL { ?position_statement pq:P580 ?start. } OPTIONAL { ?position_statement pq:P582 ?end. } } ORDER BY DESC(?date_of_birth) LIMIT 5000

Use at

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#>
# members of Massachusetts House of Representatives

SELECT ?item ?itemLabel 
?date_of_birth ?image ?electoral_district ?electoral_districtLabel ?start ?end
WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  ?item p:P39 ?position_statement.
  ?position_statement ps:P39 wd:Q17342542.
  ?position_statement wikibase:rank ?rank.
  FILTER (?rank = wikibase:PreferredRank ||
          ?rank = wikibase:NormalRank && NOT EXISTS { ?item p:P39/wikibase:rank wikibase:PreferredRank. })
  OPTIONAL { ?item wdt:P569 ?date_of_birth. }
  OPTIONAL { ?item wdt:P18 ?image. }
  OPTIONAL { ?position_statement pq:P768 ?electoral_district. }
  OPTIONAL { ?position_statement pq:P580 ?start. }
  OPTIONAL { ?position_statement pq:P582 ?end. }
}
ORDER BY DESC(?date_of_birth)
LIMIT 5000

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v1("?date_of_birth"):::projected v6("?electoral_district"):::projected v8("?end"):::projected v5("?image"):::projected v3("?item"):::projected v4("?position_statement") v2("?rank") v7("?start"):::projected a1((" ")) c1(["wikibase:PreferredRank"]):::iri c6(["bd:serviceParam"]):::iri c8(["#91;AUTO_LANGUAGE#93;,en"]):::literal c10(["wd:Q17342542"]):::iri f0[["(?rank = 'wikibase:PreferredRank' || ?rank = 'wikibase:NormalRank'not )"]] subgraph f0e0["Exists Clause"] e0v1 --"p:P39"--> e0a1 e0a1 --"wikibase:rank"--> e0c3 e0v1("?item"):::projected e0a1((" ")):::projected e0c3(["wikibase:PreferredRank"]):::iri end f0--EXISTS--> f0e0 f0 --> v2 f0 --> v3 f0 --> c3 f0 --> a1 f0 --> c4 f0 --> c1 v3 --"p:P39"--> a1 a1 --"wikibase:rank"--> c1 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c6 --"wikibase:language"--> c8 end v3 --"p:P39"--> v4 v4 --"p:statement/P39"--> c10 v4 --"wikibase:rank"--> v2 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:direct/P569".-> v1 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:direct/P18".-> v5 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v4 -."p:qualifier/P768".-> v6 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v4 -."p:qualifier/P580".-> v7 end subgraph optional4["(optional)"] style optional4 fill:#bbf,stroke-dasharray: 5 5; v4 -."p:qualifier/P582".-> v8 end