query-bbad6e45d76f98780615b1ea7a94f876
User:Bilalox01I am trying to query all the cats breeds (wd:Q43577) along with the list of cats that belong to.
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 rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?CatBreed ?CatBreedName (GROUP_CONCAT(?CatLabel; SEPARATOR=", ") AS ?CatsOfTheBreed)
WHERE
{
?CatBreed wdt:P31 wd:Q43577.
OPTIONAL { ?Cat wdt:P31 ?CatBreed. }
SERVICE wikibase:label
{
bd:serviceParam wikibase:language "en".
?CatBreed rdfs:label ?CatBreedName.
?Cat rdfs:label ?CatLabel.
}
}
GROUP BY ?CatBreed ?CatBreedName
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v2("?Cat")
v1("?CatBreed"):::projected
v3("?CatBreedName"):::projected
v4("?CatLabel"):::projected
v5("?CatsOfTheBreed")
c4(["bd:serviceParam"]):::iri
c6(["en"]):::literal
c2(["wd:Q43577"]):::iri
v1 --"wdt:P31"--> c2
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v2 -."wdt:P31".-> v1
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c4 --"wikibase:language"--> c6
v1 --"rdfs:label"--> v3
v2 --"rdfs:label"--> v4
end
bind1[/"?CatLabel"/]
v4 --o bind1
bind1 --as--o v5