在 SPARQL 中计数
好的,我有这个查询
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT DISTINCT (COUNT(?instance) AS ?count) WHERE {
?instance a <http://dbpedia.org/ontology/Ambassador> .
}
,结果是 286。很酷。现在我想获取拥有 http://dbpedia.org/property/name 属性的大使数量。但
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT DISTINCT (COUNT(?instance) AS ?count) WHERE {
?instance a <http://dbpedia.org/ontology/Ambassador> .
?instance <http://dbpedia.org/property/name> ?name
}
结果是 533 :(。所以计数更多,因为有人拥有该属性一次或多次。但是我如何获得拥有该属性的大使数量,无论他们拥有多少次。你能做吗这在一个查询中吗?
谢谢。
Ok so i have this query
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT DISTINCT (COUNT(?instance) AS ?count) WHERE {
?instance a <http://dbpedia.org/ontology/Ambassador> .
}
and the result is 286. Cool. Now I want to get the number of ambassadors that have http://dbpedia.org/property/name property. But
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT DISTINCT (COUNT(?instance) AS ?count) WHERE {
?instance a <http://dbpedia.org/ontology/Ambassador> .
?instance <http://dbpedia.org/property/name> ?name
}
results in 533 :(. So it is counting more because there are people which have this property one or more times. But how do I get the number of ambassadors that have this property regardless of how many times they have it. Can you do this in a single query?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能想尝试一下:
它给我的结果是 283,这可能正确也可能不正确:)。
You might want to try this:
It's giving me a result of 283, which might or might not be right :).