query-f252022288836a58bcae909e154190f9
This is a bit of a complicated request, so let's start with this simplified one:
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX schema: <http://schema.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel
?rank1 (GROUP_CONCAT(DISTINCT ?qual1; SEPARATOR=", ") AS ?qualifiers1)
?rank2 (GROUP_CONCAT(DISTINCT ?qual2; SEPARATOR=", ") AS ?qualifiers2)
WHERE
{
{
SELECT ?item ?GND_statement1 ?GND_statement2
WHERE
{
{
SELECT ?item
WHERE
{
?item p:P227 [].
}
GROUP BY ?item
HAVING (COUNT(?item) > 1)
} ?item p:P227 ?GND_statement1.
?item p:P227 ?GND_statement2.
FILTER (?GND_statement1 != ?GND_statement2)
FILTER (STR(?GND_statement1) < STR(?GND_statement2))
}
} ?sitelink schema:about ?item.
?sitelink schema:isPartOf <https://de.wikipedia.org/>.
?GND_statement1 wikibase:rank ?rank1.
?GND_statement2 wikibase:rank ?rank2.
OPTIONAL { ?GND_statement1 ?qualifier1 []. ?qualifierproperty1 wikibase:qualifier ?qualifier1. }
OPTIONAL { ?GND_statement2 ?qualifier2 []. ?qualifierproperty2 wikibase:qualifier ?qualifier2. }
SERVICE wikibase:label
{
bd:serviceParam wikibase:language "[AUTO_LANGUAGE],de".
?item rdfs:label ?itemLabel.
?qualifierproperty1 rdfs:label ?qual1.
?qualifierproperty2 rdfs:label ?qual2.
}
}
GROUP BY ?item ?itemLabel ?GND_statement1 ?GND_statement2 ?rank1 ?rank2
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v1("?GND_statement1")
v2("?GND_statement2")
v4("?_anon_42b5416610844a34809f33a099ae9de19086")
v3("?item"):::projected
v12("?itemLabel"):::projected
v13("?qual1"):::projected
v14("?qual2"):::projected
v8("?qualifier1")
v10("?qualifier2")
v9("?qualifierproperty1")
v11("?qualifierproperty2")
v15("?qualifiers1")
v16("?qualifiers2")
v6("?rank1"):::projected
v7("?rank2"):::projected
v5("?sitelink")
a2((" "))
a3((" "))
a4((" "))
a1((" "))
c5([https://de.wikipedia.org/]):::iri
c11(["#91;AUTO_LANGUAGE#93;,de"]):::literal
c9(["bd:serviceParam"]):::iri
f0[["str(?GND_statement1) < str(?GND_statement2)"]]
f0 --> v1
f0 --> v2
f1[["?GND_statement1 != ?GND_statement2"]]
f1 --> v1
f1 --> v2
f2[[" > '1^^xsd:integer'"]]
f2 --> a1
v3 --"p:P227"--> a2
bind4[/"count(?item)"/]
v3 --o bind4
bind4 --as--o v4
v3 --"p:P227"--> v1
v3 --"p:P227"--> v2
v5 --"schema:about"--> v3
v5 --"schema:isPartOf"--> c5
v1 --"wikibase:rank"--> v6
v2 --"wikibase:rank"--> v7
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v1 -->v8--> a3
v9 -."wikibase:qualifier".-> v8
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v2 -->v10--> a4
v11 -."wikibase:qualifier".-> v10
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c9 --"wikibase:language"--> c11
v3 --"rdfs:label"--> v12
v9 --"rdfs:label"--> v13
v11 --"rdfs:label"--> v14
end
bind7[/"?qual1"/]
v13 --o bind7
bind7 --as--o v15
bind8[/"?qual2"/]
v14 --o bind8
bind8 --as--o v16