Sparql: Arithmetic operators between variables? -
hi have query this:
select ?a ?b { ?c property:name "mything"@en ?c property:firstvalue ?b ?c property:secondvalue ?a }
how can divide first nuber , second? idealy somthing this:
select ?a/?b { ?c property:name "mything"@en ?c property:firstvalue ?b ?c property:secondvalue ?a }
thank you
in sparql 1.1 can using project expressions so:
prefix xsd: <http://www.w3.org/2001/xmlschema#> select (xsd:float(?a)/xsd:float(?b) ?result) { ?c property:name "mything"@en ?c property:firstvalue ?b ?c property:secondvalue ?a }
you may alternately use xsd:double(?var)
cast double, xsd:integer(?var)
cast integer , xsd:decimal(?var)
cast decimal.
note sparql specifies type promotion rules example:
- integer / integer = decimal
- float / double = double
if need result in guaranteed datatype can cast whole divide expression e.g.
prefix xsd: <http://www.w3.org/2001/xmlschema#> select (xsd:double(xsd:float(?a)/xsd:float(?b)) ?result) { ?c property:name "mything"@en ?c property:firstvalue ?b ?c property:secondvalue ?a }
Comments
Post a Comment