Group concat not working

前端 未结 1 899
借酒劲吻你
借酒劲吻你 2021-01-15 21:02

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

相关标签:
1条回答
  • 2021-01-15 21:56

    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
    
    0 讨论(0)
提交回复
热议问题