Hi I have a query like this:
SELECT ?a ?b
WHERE
{
?c property:name "myThing"@en
?c property:firstValue ?b
?c property:secondValue ?a
}
How can I divide the first nuber and the second? idealy somthing like this:
SELECT ?a/?b
WHERE
{
?c property:name "myThing"@en
?c property:firstValue ?b
?c property:secondValue ?a
}
Thank you
There are two ways to achieve this:
or
In SPARQL 1.1 you can do it using Project expressions like so:
You may alternately use
xsd:double(?var)
to cast to a double,xsd:integer(?var)
to cast to an integer andxsd:decimal(?var)
to cast to a decimal.Note that SPARQL specifies type promotion rules so for example:
If you really need the result in a guaranteed datatype you can cast the whole divide expression e.g.