SPARQL group by and order by: not ordered

前端 未结 2 1514
伪装坚强ぢ
伪装坚强ぢ 2021-01-23 14:08

I follow up on query where the schema.org database is used to find the number of children of a class - as a simpler database than my application. I want to get the names of the

2条回答
  •  一向
    一向 (楼主)
    2021-01-23 14:24

    An additional select subquery is required to push the order inside the groups:

    prefix schema:  
    prefix rdfs:    
    
    select    ?child  (group_concat (?string) as ?strings) 
    
    where {
        select * 
        {
         ?child  rdfs:subClassOf schema:Event .
         ?grandchild rdfs:subClassOf ?child .
         bind (strafter(str(?grandchild), "http://schema.org/") as ?string)
        } order by asc(?string)
    }   group by ?child  
    limit 20 
    

提交回复
热议问题