query-42e19b2e339136b2d1644b09905c569a
TODO
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX pr: <http://www.wikidata.org/prop/reference/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel ?pattern
#pattern 1: either more than one statement for P1532
#pattern 2: or within a single P1532 statement more than one source P248
#pattern 3: or within a single P1532 statement in the source both P248 and P143
where {
{ {select ?item ?pattern (count(?countryforsport) as ?countryforsportcount) where
{
?item wdt:P106 wd:Q10873124.
?item wdt:P1532 ?countryforsport.
bind("1" as ?pattern)
} group by ?item ?pattern having(?countryforsportcount >1) }} union { {select ?item ?pattern (count(?statedin) as ?statedincount) where
{
?item p:P1532 ?P1532statement.
?P1532statement prov:wasDerivedFrom ?refnode.
?refnode pr:P248 ?statedin.
bind("2" as ?pattern)
} group by ?item ?pattern having(?statedincount>1) }} union { {select ?item ?pattern (count(?statedin) as ?statedincount) where
{
?item p:P1532 ?P1532statement.
?P1532statement prov:wasDerivedFrom ?refnode.
?P1532statement prov:wasDerivedFrom ?refnode1.
?refnode pr:P143 ?a . # query for this on its own & it is found, but ...
?refnode1 pr:P248 ?b . # query for both, and no results. Query for this one on its own & it is found.
bind("3" as ?pattern)
} group by ?item ?pattern }}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v6("?P1532statement")
v10("?a")
v11("?b")
v3("?countryforsport")
v5("?countryforsportcount")
v2("?item"):::projected
v12("?pattern"):::projected
v7("?refnode")
v9("?refnode1")
v8("?statedin")
v12("?statedincount")
c10(["bd:serviceParam"]):::iri
c3(["wd:Q10873124"]):::iri
c12(["#91;AUTO_LANGUAGE#93;,en"]):::literal
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
subgraph union1[" Union "]
subgraph union1l[" "]
style union1l fill:#abf,stroke-dasharray: 3 3;
v2 --"p:P1532"--> v6
v6 --"prov:wasDerivedFrom"--> v7
v6 --"prov:wasDerivedFrom"--> v9
v7 --"p:reference/P143"--> v10
v9 --"p:reference/P248"--> v11
bind0[/"'3'"/]
bind0 --as--o v12
bind2[/"count(?statedin)"/]
v8 --o bind2
bind2 --as--o v12
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
f3[["?statedincount > '1^^xsd:integer'"]]
f3 --> v12
v2 --"p:P1532"--> v6
v6 --"prov:wasDerivedFrom"--> v7
v7 --"p:reference/P248"--> v8
bind4[/"'2'"/]
bind4 --as--o v12
bind6[/"count(?statedin)"/]
v8 --o bind6
bind6 --as--o v12
end
union1r <== or ==> union1l
end
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
f7[["?countryforsportcount > '1^^xsd:integer'"]]
f7 --> v5
v2 --"p:direct/P106"--> c3
v2 --"p:direct/P1532"--> v3
bind8[/"'1'"/]
bind8 --as--o v12
bind10[/"count(?countryforsport)"/]
v3 --o bind10
bind10 --as--o v5
end
union0r <== or ==> union0l
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c10 --"wikibase:language"--> c12
end