On 04/06/17 18:47, Aya Hamdy wrote:
Hello,

I wanted to add a property called avgSpeed to an instance of a class called
FlowSensor. This property should be the average of the values of the
property vehicleSpeed attached to instances of the class Vehicle.

I read that SPARQL update allows doing this. However, I cannot reach the
syntax for doing the* averaging of values* or for building the *SPARQL
Update *query using jena with eclipse on the jena website.

If Jena indeed supports doing what I intend to do then can someone point
out some sources to guide me in my attempt?

Best Regards,
Aya


Calculate the average in a nested select so somethign like (you'll have to fix this up):

INSERT {
     <instance> :avgSpeed ?avg
   }
WHERE {
   SELECT (AVG(?speed) AS ?avg) {
       ?v rdf:type :Vehicle ;
          :vehicleSpeed ?speed
   }
}

By the way - it is better to more concrete in your description - actual data for example.

Reply via email to