SPARQL HAVING子句给出语法错误

时间:2018-04-22 14:43:43

标签: sparql dbpedia

我正在尝试使用this使用以下内容从DBPedia创作超过3本书的作者:

SELECT ?author (COUNT(*) as ?count) WHERE {?works dbo:author ?author. }

Group by(?author)
ORDER BY DESC (?count)
HAVING (?count > 3)

但是我收到一个语法错误,当我删除我的HAVING子句时,其余的工作正常,任何想法可能是什么问题?

2 个答案:

答案 0 :(得分:1)

错误告诉您"?count用于聚合外的结果集"所以基本上你应该使用"聚合解决方案"您可以这样做:

SELECT ?author (COUNT(*) as ?count) WHERE {?works dbo:author ?author. }    
Group by ?author
HAVING (COUNT(*) > 3)
ORDER BY DESC (?count)

您可以看到here正式语法。

答案 1 :(得分:0)

你有: Group by(?author) ORDER BY DESC (?count) HAVING (?count > 3) 但是HAVING应该在ORDER BY之前。