php - Geting values by timestamp to find percent change. Mysql -


I want to find a change in two values ​​from a mysql database.

I have a cron job set to insert values ​​almost every hour ..

Each value has a UNIX timestamp associated with it and I have been in the last days (~ 24 hours) and want to get a percentage increase compared to the current growth. Or decrease.

The table looks like this:

  + ----- + ---- + | Price | Time | + ----- + ---- +    

The sum of values ​​from Day 2, yes? This will give you changes in the readings from calendar day.

  SELECT t1.time, (sum (t1.value) - sum (t2.value)) from table T1, table T2 where t1 date time (time_Instantime (T1 time) < / Code>   . Time & gt; t2 time and t1.time = t2.time + (60 * 60 * 24)

Comments