query-36a5fa2f3ece190da77a68a9c2047594
Illustrates optional fields, instances of subclasses, language fallback on label service, date to year conversion
Horses on Wikidata
SELECT DISTINCT ?horse ?horseLabel ?mother ?father (year(?birthdate) as ?birthyear) (year(?deathdate) as ?deathyear) ?genderLabel WHERE { ?horse wdt:P31/wdt:P279* wd:Q726 . # Instance et sous-classes de Q726-Cheval
OPTIONAL{?horse wdt:P25 ?mother .} # P25 : Mère
OPTIONAL{?horse wdt:P22 ?father .} # P22 : Père
OPTIONAL{?horse wdt:P569 ?birthdate .} # P569 : Date de naissance
OPTIONAL{?horse wdt:P570 ?deathdate .} # P570 : Date de décès
OPTIONAL{?horse wdt:P21 ?gender .} # P21 : Sexe
SERVICE wikibase:label { #BabelRainbow
bd:serviceParam wikibase:language "[AUTO_LANGUAGE],fr,ar,be,bg,bn,ca,cs,da,de,el,en,es,et,fa,fi,he,hi,hu,hy,id,it,ja,jv,ko,nb,nl,eo,pa,pl,pt,ro,ru,sh,sk,sr,sv,sw,te,th,tr,uk,yue,vec,vi,zh"
}
} ORDER BY ?horse
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 bd: <http://www.bigdata.com/rdf#>
#Illustrates optional fields, instances of subclasses, language fallback on label service, date to year conversion
#Horses on Wikidata
SELECT DISTINCT ?horse ?horseLabel ?mother ?father (year(?birthdate) as ?birthyear) (year(?deathdate) as ?deathyear) ?genderLabel
WHERE
{
?horse wdt:P31/wdt:P279* wd:Q726 . # Instance et sous-classes de Q726-Cheval
OPTIONAL{?horse wdt:P25 ?mother .} # P25 : Mère
OPTIONAL{?horse wdt:P22 ?father .} # P22 : Père
OPTIONAL{?horse wdt:P569 ?birthdate .} # P569 : Date de naissance
OPTIONAL{?horse wdt:P570 ?deathdate .} # P570 : Date de décès
OPTIONAL{?horse wdt:P21 ?gender .} # P21 : Sexe
SERVICE wikibase:label { #BabelRainbow
bd:serviceParam wikibase:language "[AUTO_LANGUAGE],fr,ar,be,bg,bn,ca,cs,da,de,el,en,es,et,fa,fi,he,hi,hu,hy,id,it,ja,jv,ko,nb,nl,eo,pa,pl,pt,ro,ru,sh,sk,sr,sv,sw,te,th,tr,uk,yue,vec,vi,zh"
}
}
ORDER BY ?horse
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v4("?birthdate"):::projected
v7("?birthyear")
v5("?deathdate"):::projected
v8("?deathyear")
v3("?father"):::projected
v6("?gender")
v1("?horse"):::projected
v2("?mother"):::projected
a1((" "))
c10(["bd:serviceParam"]):::iri
c3(["wd:Q726"]):::iri
c12(["#91;AUTO_LANGUAGE#93;,fr,ar,be,bg,bn,ca,cs,da,de,el,en,es,et,fa,fi,he,hi,hu,hy,id,it,ja,jv,ko,nb,nl,eo,pa,pl,pt,ro,ru,sh,sk,sr,sv,sw,te,th,tr,uk,yue,vec,vi,zh"]):::literal
v1 --"wdt:P31"--> a1
a1 --"wdt:P279"--> c3
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v1 -."wdt:P25".-> v2
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v1 -."wdt:P22".-> v3
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v1 -."wdt:P569".-> v4
end
subgraph optional3["(optional)"]
style optional3 fill:#bbf,stroke-dasharray: 5 5;
v1 -."wdt:P570".-> v5
end
subgraph optional4["(optional)"]
style optional4 fill:#bbf,stroke-dasharray: 5 5;
v1 -."wdt:P21".-> v6
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c10 --"wikibase:language"--> c12
end
bind0[/"year-from-dateTime(?birthdate)"/]
v4 --o bind0
bind0 --as--o v7
bind1[/"year-from-dateTime(?deathdate)"/]
v5 --o bind1
bind1 --as--o v8