(sql diffrence) job send email with total distance (last month)

Wojciech6 years ago

Hello,

I have got a problem. I want to create cron job. This job will send total distance of my device via EMAIL (every month).

I have created below query:

select SUM(CAST(substr(attributes,
       instr(attributes, '"distance"') + 11,
       instr(attributes, '"totalDistance"') -
       instr(attributes, '"distance"') - 12) as decimal(10,2))/1000)
  from positions WHERE deviceId = 1 AND fixTime BETWEEN '2018-03-01 00:00:00' AND '2018-04-01 00:00:00' ORDER BY fixTime  ;

But there is a diffrence between what I got from this query (1293.63.....) ( and what I got in traccar GUI:(1853.43).

Maybe someone is able to help me?
I have no idea what is going on...

(traccar 3.16)

Regards,
W

Anton Tananaev6 years ago

You just need a difference in totalDistance between first and last message. That's how Traccar calculates it.