On 19/08/14 11:28, Ioan SZILAGYI wrote:
Hi everybody,
I would like to know if there is a way (a function?) to specify row numbers
in a Sparql result.
No, but you can add a custom function that would do that (when used
carefully -- don't use it anywhere except in the outermost SELECT clause.)
An easier way might be to add a wrapper that adds the count onto the
emitted stream of results. You'd need access to the API call to get the
results.
Andy
On a given RDF graph :
prefix ex: <http://example.com/>
ex:idA ex:name "product A" ;
ex:storedTime "2014-08-*11*T10:00:00.000Z"^^xsd:dateTime .
ex:idB ex:name "product B" ;
ex:storedTime "2014-08-*12*T10:00:00.000Z"^^xsd:dateTime .
ex:idC ex:name "product C" ;
ex:storedTime "2014-08-*10*T10:00:00.000Z"^^xsd:dateTime .
I want to obtain an index (when ordering on other variables) integrated in
results :
-----------------------------------
| index | productId | name |
===================================
| 1 | ex:idC | "product C" |
| 2 | ex:idA | "product A" |
| 3 | ex:idB | "product B" |
-----------------------------------
Is there a rownum() function or something to do that?
SELECT (row_number() as ?index) ?productId ?name
WHERE {
?productId ex:name ?name ;
ex:storedTime ?storedTime .
}
ORDER BY ASC(?storedTime)
Until now I searched on the web (and
http://jena.apache.org/documentation/query/library-function.html ;
http://www.w3.org/TR/2010/WD-sparql11-query-20100126/#aggregateFunctions)
without success.
Thank you,
Ioan