English 中文(简体)
如何询问使用SPARQL.1.1的不同标记的数量?
原标题:How to query for the number of distinct tuples using SPARQL 1.1?

似乎有可能计算一个使用单一实体的情况。

(COUNT(DISTINCT ?x) as ?count)

and for the number of distinct tuples for all variables in the query using

(COUNT(DISTINCT *) as ?count)

However, I cannot figure out how to count specific (distinct) tuples. Something like

(COUNT(DISTINCT ?a ?b ?c) as ?count) 

似乎没有工作。 我这样做是错误的,还是实际上不允许在SPARQL 1.1中这样做? 或者,它是否应该工作,在我用来测试的Sesame 2.6.0中,它没有得到支持?

最佳回答

确保你的中间结果只包含三个变量:?a ?b ?c

One way of doing this is to use a subquery. The subquery projects only the three desired variables. Something like this:

SELECT (COUNT(*) AS ?count) {
   SELECT DISTINCT ?a ?b ?c {
      …
   }
}

(不确定Sesame是否支持分局)

另一种办法是简单地确保你的询问只包含三个变量。 如果您在询问中需要更多的变量,你可以用空白点取代。 SPARQL图表中的空白点像“匿名变量”一样。 与此相关的一些模糊问题,因此,分局办法可能更好。

问题回答

暂无回答




相关问题
SELECT command to calculate percentage

I m trying to get the percentage of each video I have in my database based on its view count against all other videos. I m then trying to display all the videos from highest view count to lowest, ...

Consolidating a COUNT query

I have a page where I am running an initial SQL query to get a list of subjects, then I loop over this query and run two additional queries for each record returned from the original subjects query (I ...

R: Count number of objects in list [closed]

Can someone recommend a function that can allow me to count and return the number of items in a list? library(stringr) l <- strsplit(words, "a") if(# number of items in list l < 1) ...

Mysql get count of rows for each day

My Current query is: SELECT DISTINCT DATE(vote_timestamp) AS Date, COUNT(*) AS TotalVotes FROM `votes` WHERE vote_target_id= 83031 GROUP BY DATE(vote_timestamp) ORDER BY DATE(vote_timestamp) DESC ...

Group by named column

I always forget how to do things like this. I have a database table with birthdates and I want to find out how many people have the same age. I m trying: SELECT TIMESTAMPDIFF( YEAR, birthdate, ...

TableView oval button for Index/counts

Can someone help me create an index/count button for a UITableView, like this one? iTunes http://img.skitch.com/20091107-nwyci84114dxg76wshqwgtauwn.preview.jpg Is there an Apple example, or other ...

热门标签