query-745e76a445e791442c6decf91d1cae28
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 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 ?item ?itemLabel ?pen1 ?pen2 ?issue
WHERE
{
?item wdt:P31 wd:Q161705.
?item p:P137 ?stat11.
?item p:P137 ?stat22.
filter(str(?stat11) > str(?stat22))
?item p:P879 ?stat1.
?item p:P879 ?stat2.
filter(str(?stat1) > str(?stat2))
{ ?stat1 ps:P879 ?pen1.
?stat2 ps:P879 ?pen2.
filter (?pen1 != ?pen2)
BIND("different pennants" as ?issue)
}
UNION
{ ?stat1 ps:P879 ?pen1.
?stat2 ps:P879 ?pen2.
filter (?pen1 = ?pen2)
OPTIONAL {?stat1 pq:P137 ?op1.}
OPTIONAL {?stat2 pq:P137 ?op2.}
filter(!BOUND(?op1)|| !BOUND(?op1))
BIND("missing operator" as ?issue)
}
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;
v11("?issue"):::projected
v5("?item"):::projected
v9("?op1")
v10("?op2")
v6("?pen1"):::projected
v7("?pen2"):::projected
v1("?stat1")
v3("?stat11")
v2("?stat2")
v4("?stat22")
c8(["bd:serviceParam"]):::iri
c2(["wd:Q161705"]):::iri
c10(["#91;AUTO_LANGUAGE#93;,en"]):::literal
f0[["str(?stat1) > str(?stat2)"]]
f0 --> v1
f0 --> v2
f1[["str(?stat11) > str(?stat22)"]]
f1 --> v3
f1 --> v4
v5 --"p:direct/P31"--> c2
v5 --"p:P137"--> v3
v5 --"p:P137"--> v4
v5 --"p:P879"--> v1
v5 --"p:P879"--> v2
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
f2[["(not bound(?op1) || not bound(?op1))"]]
f2 --> v9
f3[["?pen1 = ?pen2"]]
f3 --> v6
f3 --> v7
v1 --"p:statement/P879"--> v6
v2 --"p:statement/P879"--> v7
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v1 -."p:qualifier/P137".-> v9
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v2 -."p:qualifier/P137".-> v10
end
bind4[/"'missing operator'"/]
bind4 --as--o v11
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
f5[["?pen1 != ?pen2"]]
f5 --> v6
f5 --> v7
v1 --"p:statement/P879"--> v6
v2 --"p:statement/P879"--> v7
bind6[/"'different pennants'"/]
bind6 --as--o v11
end
union0r <== or ==> union0l
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c8 --"wikibase:language"--> c10
end