Hi,
I have gone through your description of the issue as well as the sample sql statement and have understood the issue you are facing. Essentially, in order to calculate the corrected value of the weight, you need to look at all the correction values for the preceding period (within a given datetime range). This needs to also be based on the ID value in the table (assuming that you ave multiple id's in the table each having a different set of correction values over a period of time).
I believe i can help you get the time taken for the sql query to run to a subsecond response time. I plan to use stored procedures to achieve this.
I have over 17 years of designing and developing software applications and have worked with multiple database technologies (mysql, oracledb, nosql, mongodb, sqllite etc) as well as multiple programing platforms (java, javascript, php, python, c, shell scripts etc).
As you would see from the reviews I have received on the freelancer platform, I am a serious freelancer who has a 100% completion rate with a 5 star rating. Over 33% of the projects i have done have resulted in a rehire because the employees liked the work that i did.
Looking forward to a positive response from you.
thanks