query-b2fc0e1eb6c62c193d2c71ed398c6bb0
Next, I calculated which senators were the first to serve in each seat for each congressional session.
Use at
- https://query.wikidata.org/sparql
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX wikibase: <http://wikiba.se/ontology#>
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 ?sen ?senLabel ?district ?districtLabel ?term ?termNum WHERE {
{
SELECT ?district ?term (MIN(?start) AS ?first) WHERE {
?sen p:P39 ?ps.
?ps ps:P39 wd:Q4416090;
pq:P2937 ?term;
pq:P768 ?district;
pq:P580 ?start.
FILTER ( ?start > "1913"^^xsd:dateTime )
}
GROUP BY ?district ?term
}
?sen p:P39 ?ps.
?ps ps:P39 wd:Q4416090;
pq:P2937 ?term;
pq:P768 ?district;
pq:P580 ?first.
?term (p:P31/pq:P1545) ?termNum.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY (?district) (xsd:integer(?termNum))
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v1("?district"):::projected
v7("?first")
v5("?ps")
v4("?sen"):::projected
v3("?start")
v6("?term"):::projected
v2("?termNum"):::projected
a1((" "))
c11(["bd:serviceParam"]):::iri
c4(["wd:Q4416090"]):::iri
c13(["#91;AUTO_LANGUAGE#93;,en"]):::literal
f0[["?start > '1913^^xsd:dateTime'"]]
f0 --> v3
v4 --"p:P39"--> v5
v5 --"p:statement/P39"--> c4
v5 --"p:qualifier/P2937"--> v6
v5 --"p:qualifier/P768"--> v1
v5 --"p:qualifier/P580"--> v3
bind2[/"min(?start)"/]
v3 --o bind2
bind2 --as--o v7
v4 --"p:P39"--> v5
v5 --"p:statement/P39"--> c4
v5 --"p:qualifier/P2937"--> v6
v5 --"p:qualifier/P768"--> v1
v5 --"p:qualifier/P580"--> v7
v6 --"p:P31"--> a1
a1 --"p:qualifier/P1545"--> v2
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c11 --"wikibase:language"--> c13
end