[英]FILTER with MIN in SPARQL
我正在編寫以下SPARQL查詢。
select ?o1, ?o2, ?e from <http://ndssl.bi.vt.edu/chicago/>
where{
?s <http://ndssl.bi.vt.edu/chicago/vocab/dendrogram_infector_pid> ?o1.
?s <http://ndssl.bi.vt.edu/chicago/vocab/dendrogram_infectee_pid> ?o2.
?s <http://ndssl.bi.vt.edu/chicago/vocab/dendrogram_iteration> '0'^^xsd:decimal.
?s <http://ndssl.bi.vt.edu/chicago/vocab/dendrogram_exposureday> ?e.
?s1 <http://ndssl.bi.vt.edu/chicago/vocab/contactnetwork_pid1> ?o1.
?s1 <http://ndssl.bi.vt.edu/chicago/vocab/contactnetwork_pid2> ?o2.
?s1 <http://ndssl.bi.vt.edu/chicago/vocab/contactnetwork_acttype1> '5'^^xsd:decimal.
?s1 <http://ndssl.bi.vt.edu/chicago/vocab/contactnetwork_acttype1> '5'^^xsd:decimal
}
查詢返回結果如下。
<http://ndssl.bi.vt.edu/chicago/person/pid#449563560> <http://ndssl.bi.vt.edu/chicago/person/pid#446718746> 32
<http://ndssl.bi.vt.edu/chicago/person/pid#449563560> <http://ndssl.bi.vt.edu/chicago/person/pid#446734805> 5
<http://ndssl.bi.vt.edu/chicago/person/pid#450309500> <http://ndssl.bi.vt.edu/chicago/person/pid#450261482> 30
我只需要“?e”最小的三元組。 這意味着:
<http://ndssl.bi.vt.edu/chicago/person/pid#449563560> <http://ndssl.bi.vt.edu/chicago/person/pid#446734805> 5
我該怎么做? 我嘗試了以下操作,但不起作用。
.............
?s <http://ndssl.bi.vt.edu/chicago/vocab/dendrogram_exposureday> ?e.FILTER (MIN (?e))
.............
我需要在“ WHERE”子句中找到對象“?e”的最小值,因為查詢的其他部分取決於它。
如果要以最小的值獲得結果,最簡單的方法是按該值排序並將解決方案的數量限制為一個。 例如(您應該能夠將此技術應用於查詢):
select ?x {
values ?x { 8 2 0 2 -3 1 5 }
}
order by ?x
limit 1
這將產生-3作為唯一結果,因為它是在訂購結果之后首先出現的,並且只有第一個結果被限制所允許。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.