Hi, I have a table with number of page views per day. Something like this:
+------+------------+------+
| id | date | hits |
+------+------------+------+
| 4876 | 2009-07-14 | 4362 |
+------+------------+------+
| 4876 | 2009-07-15 | 1324 |
+------+------------+------+
| 7653 | 2009-06-09 | 5643 |
+------+------------+------+
I need to create a function that compares the total hits between last two weeks and get the porcentage of change (popularity).
If the first week I have 1000 hits and the second week 2000 hits I have +200% of popularity
[ (1000 * 2000) / 100 ] = 200
If the first week I have more hits than in the second week the popularity will be in minus (-80% for example)
I have some questions:
1) I'm using the correct math formula??
2) How I select in MySQL the last two weeks from now?
3) Its possible that the first week we have hits, but the second week no hits at all so the table row will be empty for those dates or those specific days that there were no hits.. Is this a problem?
4) I'm sure there is a better way for doing this kind of statistics.. Some better ideas????