I am having an issue when concatenating in SPARQL using the Wikidata Query Service. https://query.wikidata.org/
What I want to do is retrieve all persons with a GTAA ID (?q wdt:P1741 ?GTAA_ID.) and specifically persons who have an occupation listed in Wikidata. (?q wdt:P106 ?occupation.) Furthermore, I want these occupations to be concatenated into a single row, separated by ", ".
What I am getting as of now is the name of the person in the first column, and in the second column their occupations. However, these occupations are listed as URLs to the corresponding Wikidata page. What I want is for these URLs to be displayed as Labels (the text corresponding to the Wikidata Page)
This is the code I have so far:
SELECT
?qLabel
(group_concat(DISTINCT ?occupation;separator=", ") as ?occupations )
WHERE
{
?q wdt:P1741 ?GTAA_ID.
?q wdt:P106 ?occupation.
SERVICE wikibase:label { bd:serviceParam wikibase:language "
[AUTO_LANGUAGE]". }
}
GROUP BY ?qLabel
So instead of returning for example:
Ludwig van Beethoven | http://www.wikidata.org/entity/Q36834
I would like it to return:
Ludwig van Beethoven | composer