I have one table which is having three fields:
Id, Creation Time, Fuel Level
Every two minutes we are getting data and inserting to database.For generating a fuel credit/debit statement i want to get starting(Stating of the day) and ending(End of the Day) Fuel Level.Can anyone help to form a query to generate this report?
Search parameters will be date range.
Id=10;creation time =2019-02-15 16:32:59;Fuel Level =20
I created one sample schema here
http://sqlfiddle.com/#!2/76dd5
First, for a query that provides the change in fuel for each vehicle for each day, you can use the following SQL:
If you want the Cumulative change in fuel across all vehicles for each day in the range, the following SQL should work:
Hope this helps!
john…