I\'ve written a query without using group_concat and get 9 rows returned, one row for each occupation that Einstein held.
When I add group_concat on the occupation c
The rough idea is to use dedicated SPARQL triple patterns for getting the label instead of the "label service":
SELECT ?item ?itemLabel ?genderLabel (GROUP_CONCAT(?occupationLabel) AS ?occupations)
WHERE {
?item wdt:P31 wd:Q5.
?item ?label "Albert Einstein"@en.
?item wdt:P21 ?gender .
OPTIONAL {
?item wdt:P106 ?occupation .
}
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en".
?item rdfs:label ?itemLabel .
?gender rdfs:label ?genderLabel .
?occupation rdfs:label ?occupationLabel
}
}
GROUP BY ?item ?itemLabel ?genderLabel