I was wondering if there is a way to get the functionality of SQL LAG() in my SPARQL query. More specifically, I have a set of states like
<http:\\stateA> p:start "2014-05-23T10:20:13+05:30"^^xsd:dateTime
<http:\\stateB> p:start "2014-06-23T10:20:13+05:30"^^xsd:dateTime
<http:\\stateC> p:start "2014-07-23T10:20:13+05:30"^^xsd:dateTime
And I want to find the duration of each state. The duration of each state, lets say state A, can be computed by subtracting the start of the next state (here it is state B) from the start of state A. So I need a way to find the next state with respect to each state.