【发布时间】:2021-12-07 17:36:29
【问题描述】:
我想问wikidata 哪些河流有多个大城市。以下查询为我提供了一个列表,其中?citycount 是一个介于 1 到 13 之间的整数。
# rivers and cities
SELECT ?river ?riverLabel (COUNT(?city) AS ?citycount)
WHERE {
?river wdt:P31 wd:Q4022. # ... is a river
?city wdt:P31 wd:Q1549591. # ... is a big city
?city wdt:P206 ?river. # ... located in or next to body of water
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]".}
}
GROUP BY ?river ?riverLabel
ORDER BY DESC(?citycount)
LIMIT 100
如何将结果限制在?citycount 大于 3 的河流?
【问题讨论】:
-
HAVING(?citycount > 3)- 查看规格w3.org/TR/sparql11-query/#having -
我已经尝试过了,但是把那个子句放在
ORDER BY ...之后的最后,这给了我一个Query is malformed-错误。现在它起作用了。谢谢!我猜你故意选择评论而不是常规答案?对于复制过去的能力,我自己回答了这个问题,但我当然可以删除它以支持您的常规回答。
标签: sparql aggregation wikidata