query-77c980a0a403f84042a289a0b2803817

rq turtle/ttl

TODO

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#>
select ?MP ?MPLabel ?districtLabel ?partyLabel ?assumedOffice ?endTime (sample(?image) as ?image) ?legislatureLabel ?pgroupLabel where {

 # Get all senators
 ?MP p:P39 ?posheld; # With position held
          p:P102 ?partystatement. # And with a certain party

 # Get the party
 ?partystatement ps:P102 ?party.
 #minus { ?partystatement pq:P582 ?partyEnd. } # but minus the ones the senator is no longer a member of
 #minus { ?party wdt:P361 ?partOf. } # and the 'Minnesota Democratic–Farmer–Labor Party' and such

 # define which legislatures are of interest
  VALUES ?legislature {wd:Q77345372} 

 # Check on the position in the CD
 ?posheld ps:P39 wd:Q18171345; # Position held is in the CD
          pq:P768 ?district;
          pq:P580 ?assumedOffice; # And should have a starttime
          pq:P582 ?endTime .
  ?posheld pq:P2937 ?legislature . 
  OPTIONAL { ?posheld pq:P4100 ?pgroup . }

 #minus { ?posheld pq:P582 ?endTime. } # But not an endtime 

 # Add an image
 #optional { ?senator wdt:P18 ?image. }

 service wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }

} group by ?MP ?MPLabel ?districtLabel ?partyLabel ?assumedOffice ?endTime  ?legislatureLabel ?pgroupLabel order by ?deputy

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v2("?MP"):::projected v8("?assumedOffice"):::projected v1("?deputy") v7("?district") v9("?endTime"):::projected v12("?image"):::projected v6("?legislature") v5("?party") v4("?partystatement") v10("?pgroup") v3("?posheld") c5(["wd:Q18171345"]):::iri c12(["bd:serviceParam"]):::iri c14(["#91;AUTO_LANGUAGE#93;,en"]):::literal v2 --"p:P39"--> v3 v2 --"p:P102"--> v4 v4 --"p:statement/P102"--> v5 bind0[/VALUES ?legislature/] bind0-->v6 bind00(["wd:Q77345372"]) bind00 --> bind0 v3 --"p:statement/P39"--> c5 v3 --"p:qualifier/P768"--> v7 v3 --"p:qualifier/P580"--> v8 v3 --"p:qualifier/P582"--> v9 v3 --"p:qualifier/P2937"--> v6 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:qualifier/P4100".-> v10 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c12 --"wikibase:language"--> c14 end bind2[/"sample(?image)"/] v12 --o bind2 bind2 --as--o v12