There is no ability to perform aggregates, ie, computations on a set of results. Example: find authors who have written 2 or more books. Solution: SELECT ?author WHERE { ?author v:wrote ?book1 . ?author v:wrote ?book2 . FILTER (?book1 != ?book2) } Now try to find authors who have written 50 or more books. This will require 50 book variables and 50*49/2 filter predicates. It would be easier if there were a way to count the number of books that an author has and then filter on the count. Other commonly used aggregates are sum, average, maximum, minimum. I don't know of any workaround at all for computing sum or average in SPARQL. There is a workaround for maximum and minimum, though it is messy. Example: find the vendor with the lowest price for a widget. SELECT ?vendor WHERE { ?vendor v:sells ?product . ?product a w:idget . ?product v:price ?price . ?vendor2 v:sells ?product2 . ?product2 a w:idget . ?product2 v:price ?price2 . FILTER (?price2 > ?price) } Fred ZemkeReceived on Thursday, 12 January 2006 21:43:47 GMT
This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 8 January 2008 14:14:49 GMT