query-4e24172961d6a1d7896c3627fc8a8ddd

rq turtle/ttl

Illustrates optional fields, instances of subclasses, language fallback on label service, date to year conversion

title: Hästar på Wikidata

SELECT DISTINCT ?horse ?horseLabel ?mother ?motherLabel ?father ?fatherLabel (year(?birthdate) as ?birthyear) (year(?deathdate) as ?deathyear) ?genderLabel WHERE { ?horse wdt:P31/wdt:P279* wd:Q726 . # Instance of and subclasses of Q726 (horse)

OPTIONAL{?horse wdt:P25 ?mother .} # mother OPTIONAL{?horse wdt:P22 ?father .} # father OPTIONAL{?horse wdt:P569 ?birthdate .} # date of birth OPTIONAL{?horse wdt:P570 ?deathdate .} # date of death OPTIONAL{?horse wdt:P21 ?gender .} # sex or gender

SERVICE wikibase:label { #BabelRainbow bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,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

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
#title: Hästar på Wikidata
SELECT DISTINCT ?horse ?horseLabel ?mother ?motherLabel ?father ?fatherLabel (year(?birthdate) as ?birthyear) (year(?deathdate) as ?deathyear) ?genderLabel
WHERE
{
  ?horse wdt:P31/wdt:P279* wd:Q726 .     # Instance of and subclasses of Q726 (horse)

  OPTIONAL{?horse wdt:P25 ?mother .}     # mother
  OPTIONAL{?horse wdt:P22 ?father .}     # father
  OPTIONAL{?horse wdt:P569 ?birthdate .} # date of birth
  OPTIONAL{?horse wdt:P570 ?deathdate .} # date of death
  OPTIONAL{?horse wdt:P21 ?gender .}     # sex or gender

  SERVICE wikibase:label { #BabelRainbow
    bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,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;,mul,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