我正在尝试使用this使用以下内容从DBPedia创作超过3本书的作者:
SELECT ?author (COUNT(*) as ?count) WHERE {?works dbo:author ?author. }
Group by(?author)
ORDER BY DESC (?count)
HAVING (?count > 3)
但是我收到一个语法错误,当我删除我的HAVING子句时,其余的工作正常,任何想法可能是什么问题?
答案 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
之前。