I have a bunch of RDF Data Cube observations that have an attached attribute, in my case the date on when that value was recorded.
The pattern is simple, for example (leaving out other dimension/measure/attributes):
<obs1> a qb:Observation ;
my:lastupdate '2017-12-31'^^xsd:date ;
qb:dataSet <dataSet1> .
<obs2> a qb:Observation ;
my:lastupdate '2016-12-31'^^xsd:date ;
qb:dataSet <dataSet1> .
<obs2_1> a qb:Observation ;
my:lastupdate '2017-12-31'^^xsd:date ;
qb:dataSet <dataSet2> .
<obs2_2> a qb:Observation ;
my:lastupdate '2015-12-31'^^xsd:date ;
qb:dataSet <dataSet2> .
So I have multiple qb:DataSet
in my store. Now I would like to figure out the last X my:lastupdate
values per dataset. Let's say I want the last 5 values, for each particular DataSet.
I can do that very easily for one particular dataset:
SELECT * WHERE {
?observation my:lastupdate ?datenstand ;
qb:dataSet <dataSet1>
} ORDER BY DESC(?datenstand) LIMIT 5
But I'm a bit lost if this is at all possible within a single SPARQL query, per dataset. I tried various combination with sub-selects, LIMIT & GROUP BY combinations but nothing lead to the result I am looking for.