This query using label variables from the query service ( ?profLabel ) with the aggregation function works fine. But I had to explicitely name the ?profLabel variable in the wkibase:label call. I’d had expected the next query to work also (same without doing the explicit naming) but it does not work, blazegraph seem to not pick up the autonamed variables to work in agregation functions.
```sparql
select ?personne ?nombre_profession ?personneLabel (group_concat(?profLabel;separator=" ; ") as ?professions)
with {
select ?personne (count(?prof) as ?nombre_profession) {
?personne wdt:P106 ?prof .
service bd:sample {
?personne wdt:P31 wd:Q5 .
# optional service params for the sample
bd:serviceParam bd:sample.limit 100000 .
#bd:serviceParam bd:sample.seed 0 .
bd:serviceParam bd:sample.sampleType "RANDOM" .
}
} group by ?personne having (?nombre_profession > 3)
} as %sample
with {
select ?personne ?personneLabel ?nombre_profession ?prof ?profLabel {
include %sample
?personne wdt:P106 ?prof .
#?personne rdf:laber ?personneLabel filter (lang(?personneLabel) = "fr" or lang(?personneLabel) = "en" )
SERVICE wikibase:label {
bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
?prof rdfs:label ?profLabel .
?personne rdfs:label ?personneLabel .
}
}
} as %labelled_sample
{
include %labelled_sample
} group by ?personne ?personneLabel ?nombre_profession
order by desc(?nombre_profession)
```
```sparql
select ?personne ?nombre_profession ?personneLabel (group_concat(?profLabel;separator=" ; ") as ?professions)
with {
select ?personne (count(?prof) as ?nombre_profession) {
?personne wdt:P106 ?prof .
service bd:sample {
?personne wdt:P31 wd:Q5 .
# optional service params for the sample
bd:serviceParam bd:sample.limit 100000 .
#bd:serviceParam bd:sample.seed 0 .
bd:serviceParam bd:sample.sampleType "RANDOM" .
}
} group by ?personne having (?nombre_profession > 3)
} as %sample
with {
select ?personne ?personneLabel ?nombre_profession ?prof ?profLabel {
include %sample
?personne wdt:P106 ?prof .
#?personne rdf:laber ?personneLabel filter (lang(?personneLabel) = "fr" or lang(?personneLabel) = "en" )
SERVICE wikibase:label {
bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".
}
}
} as %labelled_sample
{
include %labelled_sample
} group by ?personne ?personneLabel ?nombre_profession
order by desc(?nombre_profession)
```