Použijte DATEDIFF
funkce.
Dotaz
SELECT id,hits,created,
hits/(DATEDIFF(NOW(),created)) AS Frequency
FROM images
ORDER BY Frequency DESC;
Výstup
+----+------+---------------------------------+-----------+
| ID | HITS | CREATED | FREQUENCY |
|----+------+---------------------------------+-----------+
| 2 | 8 | November, 10 2014 05:10:20+0000 | 8 |
| 1 | 10 | November, 07 2014 11:07:57+0000 | 2.5 |
| 3 | 70 | October, 04 2014 08:04:22+0000 | 1.8421 |
+----+------+---------------------------------+-----------+