gpt4 book ai didi

SPARQL group by 和 order by : not ordered

转载 作者:行者123 更新时间:2023-12-04 12:46:11 36 4
gpt4 key购买 nike

我跟进 query其中 schema.org 数据库用于查找类的子级数量 - 作为比我的应用程序更简单的数据库。我想按字母顺序连接 child 的名字。查询:

prefix schema:  <http://schema.org/>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>

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


schema:PublicationEvent   "OnDemandEvent BroadcastEvent"
schema:UserInteraction "UserPageVisits UserComments UserPlays UserBlocks UserDownloads UserPlusOnes UserLikes UserCheckins UserTweets"

这不是按字母顺序排列的。如果我将排序顺序替换为 desc结果完全一样。我好像不明白怎么 group by , order by可能还有 bind相互影响。

最佳答案

附加 select需要子查询来推送组内的订单:

prefix schema:  <http://schema.org/>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>

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

关于SPARQL group by 和 order by : not ordered,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47460803/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com