SPARQL examples
This page is parsed by the web interface of the query service to fill the query example dialog.
Institutions
SELECT ?institution ?institutionLabel
WHERE
{
?institution wdt:P47 wd:Q467. # instance of Institution
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Humans
#Lists all humans with values of selected fields
SELECT ?human ?humanLabel ?fatherLabel ?motherLabel ?date_of_birth WHERE {
?human wdt:P47 wd:Q32.
OPTIONAL { ?human wdt:P66 ?father. }
OPTIONAL { ?human wdt:P68 ?mother. }
OPTIONAL { ?human wdt:P7 ?date_of_birth. }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Humans without parents
#Lists all humans without parents
SELECT ?human ?humanLabel WHERE {
?human wdt:P47 wd:Q32. #find humans
MINUS {
?human wdt:P68 [] . # without father
?human wdt:P66 [] . # without mother
?human wdt:P65 [] . # without any unspecified parent
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Elements from Bogumiłowice
SELECT ?item ?itemLabel WHERE {
?item wdt:P30 wd:Q24. # element posiada właściwość miejsca i ta właściwość ma wartość Bogumiłowice
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Osoby urodzone między rokiem 1501 a 1525
SELECT DISTINCT ?item ?itemLabel WHERE {
?item wdt:P47 wd:Q32.
?item wdt:P7 ?birthdate.
FILTER((?birthdate >= "1501-01-01T00:00:00Z"^^xsd:dateTime) && (?birthdate <= "1525-12-31T00:00:00Z"^^xsd:dateTime))
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Osoby o nazwisku Tarnowska/Tarnowski
SELECT DISTINCT ?item ?itemLabel ?title ?tom
WHERE
{
?item wdt:P47 wd:Q32 . # człowiek
?item wdt:P17 ?biogram . # posiadający właściwość opisano w źródle
?biogram wdt:P47 wd:Q708 . # która jest elementem bądącym rozdziałem
?biogram wdt:P106 ?title . # tytuł biogramu
?biogram wdt:P167 ?book . # publikacja, tom PSB
?book wdt:P107 ?tom . # tytuł tomu PSB
{?item wdt:P183 wd:Q23187 .} # element z właściwością family name = elementowi Tarnowski
UNION
{?item wdt:P183 wd:Q4511 . } # element z właściwością family name = elementowi Tarnowska
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY ?itemLabel