Query I'm using:
SELECT COUNT(*),
SUM(amount) AS amount,
FROM_UNIXTIME(added, '%W (%e/%m)') AS daily
FROM affiliates_earnings
WHERE added >= '1319074836'
AND added <= '1319679636'
GROUP BY daily
Output:
+----------+--------+-------------------+
| COUNT(*) | amount | daily |
+----------+--------+-------------------+
| 1 | 195 | Tuesday (25/10) |
| 4 | 470 | Wednesday (26/10) |
+----------+--------+-------------------+
What I would like to show up:
+-------+----------+--------+-------------------+
| i |COUNT(*) | amount | daily |
+-------+----------+--------+-------------------+
| 1 | 1 | 195 | Tuesday (25/10) |
| 2 | 4 | 470 | Wednesday (26/10) |
+-------+----------+--------+-------------------+
Essentially i
would be the sequential number (i.e. 1,2,3,4,5,6...).
How would I accomplish this?
Without ROW_NUMBER(), you can fake it per this answer or this one:
Doing this is almost nonsense, but if your really want, try this way: