Structure of my table : ID(int) | NUMBER(int) | CREATED_AT(date)
If I have three numbers : 10
, 11
and 9
, Can I get all rows from my table with same ratio of NUMBER
values with decreasing consecutive CREATED_AT
dates?
Examples :
If my numbers are : 10,11,9 ... The rows may be :
NUMBER | CREATED_AT
50 | 2012-03-18
51 | 2012-03-17
49 | 2012-03-16
Result must be "50"
If my numbers are : 50,40,60 ... The rows may be :
NUMBER | CREATED_AT
100 | 2012-02-20
90 | 2012-02-19
110 | 2012-02-18
Result must be "100"
...
I wasted a half of day for this, but I still have no Idea where to start...
P.S : I have about 5 000 rows in my table.
UPDATE
I did it with a bit of php code and a lot of mysql queries. Script execution time : ~6 seconds. [Tested on godaddy deluxe hosting] =)