sparql - SPARQL wikidata group-by:拥有多个城市的河流
问题描述
我想问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 的河流?
解决方案
将@UninformedUser 的评论变成答案:
# 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
HAVING (?citycount > 3) # ← important line
ORDER BY DESC(?citycount)
推荐阅读
- linux - 添加特定包后,Yocto Image 文件大小减小
- sql - 如果它们有一个索引oracle,如何更改列中的所有记录
- google-cloud-platform - 无法创建正常运行时间检查
- visual-c++ - 我无法为全局变量数组赋值
- php - Laravel 表单验证问题(会话大小限制?)
- database - 查询或扫描具有与选项列表匹配的属性的所有行的 DynamoDB
- node.js - 为什么 NPM 在明确安装时会要求对等 dep?
- javascript - 查找并删除撇号和之前的一个字母?
- php - WooCommerce 预订:在确认电子邮件中回显预订时间和日期
- java - Spring安全性@PreAuthorize注释的间歇性问题