query-dcea4c52c29f3a30583b6d6359f7fee1
Cats SELECT distinct ?item ?itemLabel ?item2 ?item2Label WHERE { ?item wdt:P106 wd:Q10833314. ?item2 wdt:P106 wd:Q10833314. {?item wdt:P3373 ?item2 .} UNION {?item2 wdt:P3373 ?item .} filter (strafter(str(?item),"Q") < strafter(str(?item2),"Q") ) #remove if you wish ?item rdfs:label ?itemLabel . filter(lang(?itemLabel)="en") ?item2 rdfs:label ?item2Label . filter(lang(?item2Label)="en") bind(strafter(?itemLabel, " ") as ?index) bind(strbefore(?itemLabel, " ") as ?index2) } order by ?index ?index2
Use at
- https://query.wikidata.org/sparql
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
#Cats
SELECT distinct ?item ?itemLabel ?item2 ?item2Label
WHERE
{
?item wdt:P106 wd:Q10833314.
?item2 wdt:P106 wd:Q10833314.
{?item wdt:P3373 ?item2 .}
UNION
{?item2 wdt:P3373 ?item .}
filter (strafter(str(?item),"Q") < strafter(str(?item2),"Q") ) #remove if you wish
?item rdfs:label ?itemLabel . filter(lang(?itemLabel)="en")
?item2 rdfs:label ?item2Label . filter(lang(?item2Label)="en")
bind(strafter(?itemLabel, " ") as ?index)
bind(strbefore(?itemLabel, " ") as ?index2)
} order by ?index ?index2
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v7("?index")
v7("?index2")
v5("?item"):::projected
v6("?item2"):::projected
v3("?item2Label"):::projected
v4("?itemLabel"):::projected
c4(["wd:Q10833314"]):::iri
f0[["?item2Label = 'en'"]]
f0 --> v3
f1[["?itemLabel = 'en'"]]
f1 --> v4
f2[["substring-after(str(?item),'Q') < substring-after(str(?item2),'Q')"]]
f2 --> v5
f2 --> v6
v5 --"wdt:P106"--> c4
v6 --"wdt:P106"--> c4
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
v6 --"wdt:P3373"--> v5
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v5 --"wdt:P3373"--> v6
end
union0r <== or ==> union0l
end
v5 --"rdfs:label"--> v4
v6 --"rdfs:label"--> v3
bind3[/"substring-after(?itemLabel,' ')"/]
v4 --o bind3
bind3 --as--o v7
bind4[/"substring-before(?itemLabel,' ')"/]
v4 --o bind4
bind4 --as--o v7