WmZilla - Webmaster and Marketplace

The Next Generation Webmaster and Trade Forum

Expert Question!

JERRY

New member

0

0%

Status

Offline

Posts

27

Likes

0

Rep

0

Bits

145

8

Months of Service

0%
I have a table structured as follows with a counter value obtained every 5 minutes. You can think of this counter as the odometer of a vehicle. I would like to create a view in MySQL to display the distance traveled each hour by subtracting the counter value at the beginning of each hour from the counter value at the previous hour. For example, to find the distance traveled between 11:00 - 12:00, I need to subtract the value at ID 25 from the value at ID 13, which is 3779723 - 3779217 = 506 km. Could you please help me by writing a view that calculates the difference in counter values at the beginning of each hour? The desired output of the view should be sorted as follows:

10:00 - 11:00 => 484
11:00 - 12:00 => 506
12:00 - 13:00 => 477

I am struggling with this task; your assistance would be greatly appreciated.
 

254

6,645

6,665

Top