Reputation: 21
I'm studying non-temporal SPARQL Queries and I'm a bit confused about the concept of RDF triples..
Say, I want to find all employees that cancelled a job and then later chose to complete the same job that they cancelled. So how can I store the date that they cancelled the job and the date they chose to do the same job?
Would the following work?
SELECT ?emp
WHERE
{
?emp :cancelledJob ?job
?emp :dateCancelled ?date1
?emp :selectedJob ?job
?emp :dateSelectedJob ?date2
FILTER(?date1 < ?date2)
}
Upvotes: 1
Views: 4247
Reputation: 85853
Your query will work if the values of ?date1 and ?date2 are such that they comparable with < as defined in the standard, or if the specific implementation that you're using extends the < operator to handle them. The operator mapping for SPARQL is given in the standard, at 17.3 Operator Mapping. The datatypes that the standard dictates, along with their mappings are:
numeric op:numeric-less-than(A, B)
simple literal op:numeric-equal(fn:compare(A, B), -1)
xsd:string op:numeric-equal(fn:compare(STR(A), STR(B)), -1)
xsd:boolean op:boolean-less-than(A, B)
xsd:dateTime op:dateTime-less-than(A, B)
So, if your dates are any of those types, your query will work. Some implementations might handle additional types, too.
Upvotes: 3