Reputation: 271774
In my Wikidata query, I actually have 2 problems.
SELECT ?person ?label ?dob ?gender ?description
WHERE
{
?person wdt:P31 wd:Q5;
rdfs:label ?label.
FILTER(STRSTARTS(?label, "Michael Bloom")).
}
GROUP BY ?person ?label
LIMIT 5
Upvotes: 0
Views: 359
Reputation: 635
SPARQL
can't guess where to get them), with the exception of labels and descriptions when using Wikibase Label Service.SELECT
must be in the GROUP BY
clause, with the exception of the use of the GROUP_CONCAT
function that will concatenate all values into one field.Here is an example of your query rewritten:
SELECT ?person ?personLabel ?personDescription (GROUP_CONCAT(DISTINCT ?dob ; SEPARATOR = ' / ') AS ?dob) (GROUP_CONCAT(DISTINCT ?gender ; SEPARATOR = ' / ') AS ?gender)
WHERE {
SERVICE wikibase:mwapi {
bd:serviceParam wikibase:api "EntitySearch" .
bd:serviceParam wikibase:endpoint "www.wikidata.org" .
bd:serviceParam mwapi:search "Michael Bloom" .
bd:serviceParam mwapi:language "en" .
?person wikibase:apiOutputItem mwapi:item .
}
?person wdt:P31 wd:Q5 .
OPTIONAL { ?person wdt:P569 ?dob }
OPTIONAL { ?person wdt:P21 ?gender }
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" . }
}
GROUP BY ?person ?personLabel ?personDescription
Upvotes: 2