query-a3bcc128eee14223b2957f18fcab9633
TODO
Use at
- https://query.wikidata.org/sparql
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#>
#defaultView:LineChart
SELECT (str(?date) as ?d) (str(?count) as ?c)
WHERE
{
{
SELECT ?date (count(?MP) as ?count) WHERE {
{
SELECT ?item ?date WHERE {
?item wdt:P31 wd:Q47150325.
?item wdt:P585 ?date .
filter("2021-01-01"^^xsd:date <= ?date && ?date < "2022-01-01"^^xsd:date )
} } ?MP p:P39 ?stat .
?stat ps:P39 wd:Q77685926.
filter not exists {?stat pq:P580 ?start . filter(?start > ?date ) }
filter not exists {?stat pq:P582 ?end . filter(?end < ?date ) }
filter not exists {
?stat pq:P582 ?endt .
?MP p:P39 ?stat2 .
?stat2 ps:P39 wd:Q77685926.
?stat2 pq:P580 ?endt .
filter(str(?stat2) != str(?stat))
filter(?endt = ?date)
}
} group by ?date }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} order by desc(?date)
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v5("?MP")
v11("?c")
v9("?count"):::projected
v10("?d")
v1("?date"):::projected
v6("?end")
v2("?endt")
v8("?item")
v7("?start")
v4("?stat")
v3("?stat2")
c9(["wd:Q47150325"]):::iri
c12(["bd:serviceParam"]):::iri
c14(["#91;AUTO_LANGUAGE#93;,en"]):::literal
c4(["wd:Q77685926"]):::iri
f0[["not "]]
subgraph f0e0["Exists Clause"]
e0f0[["?endt = ?date"]]
e0f0 --> e0v1
e0f0 --> e0v2
e0f1[["str(?stat2) != str(?stat)"]]
e0f1 --> e0v3
e0f1 --> e0v4
e0v4 --"p:qualifier/P582"--> e0v1
e0v5 --"p:P39"--> e0v3
e0v3 --"p:statement/P39"--> e0c4
e0v3 --"p:qualifier/P580"--> e0v1
e0v5("?MP"):::projected
e0v2("?date"):::projected
e0v1("?endt"):::projected
e0v4("?stat"):::projected
e0v3("?stat2"):::projected
e0c4(["wd:Q77685926"]):::iri
end
f0--EXISTS--> f0e0
f0 --> v2
f0 --> v1
f0 --> v3
f0 --> v4
f0 --> c1
f0 --> v5
f0 --> c2
f0 --> c3
f0 --> c4
f0 --> c5
f1[["?endt = ?date"]]
f1 --> v2
f1 --> v1
f2[["str(?stat2) != str(?stat)"]]
f2 --> v3
f2 --> v4
v4 --"p:qualifier/P582"--> v2
v5 --"p:P39"--> v3
v3 --"p:statement/P39"--> c4
v3 --"p:qualifier/P580"--> v2
f3[["not "]]
subgraph f3e1["Exists Clause"]
e1f0[["?end < ?date"]]
e1f0 --> e1v1
e1f0 --> e1v2
e1v3 --"p:qualifier/P582"--> e1v1
e1v2("?date"):::projected
e1v1("?end"):::projected
e1v3("?stat"):::projected
end
f3--EXISTS--> f3e1
f3 --> v6
f3 --> v1
f3 --> v4
f3 --> c1
f4[["?end < ?date"]]
f4 --> v6
f4 --> v1
v4 --"p:qualifier/P582"--> v6
f5[["not "]]
subgraph f5e2["Exists Clause"]
e2f0[["?start > ?date"]]
e2f0 --> e2v1
e2f0 --> e2v2
e2v3 --"p:qualifier/P580"--> e2v1
e2v2("?date"):::projected
e2v1("?start"):::projected
e2v3("?stat"):::projected
end
f5--EXISTS--> f5e2
f5 --> v7
f5 --> v1
f5 --> v4
f5 --> c5
f6[["?start > ?date"]]
f6 --> v7
f6 --> v1
v4 --"p:qualifier/P580"--> v7
f7[["'2021-01-01^^xsd:date' <= ?date?date < '2022-01-01^^xsd:date'"]]
f7 --> v1
v8 --"p:direct/P31"--> c9
v8 --"p:direct/P585"--> v1
v5 --"p:P39"--> v4
v4 --"p:statement/P39"--> c4
bind9[/"count(?MP)"/]
v5 --o bind9
bind9 --as--o v9
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c12 --"wikibase:language"--> c14
end
bind10[/"str(?date)"/]
v1 --o bind10
bind10 --as--o v10
bind11[/"str(?count)"/]
v9 --o bind11
bind11 --as--o v11