I have a simple stats query in mysql.
I had it working using php but was keen to keep it in the database so I found another question on it here. Thanks to that I have it working in mysql now.
I need to get a running total count of records submitted per day.
I have the running total working but no matter what I change it simply will not order by day.
It will order by the running total column but not the day.
Any input is appreciated.
SET @runtot:=0;
SELECT
q1.`Day` AS 'Days of month',
q1.`Record count` AS 'Record count',
(@runtot := @runtot + q1.`Record count`) AS 'rt'
FROM
(SELECT
FROM_UNIXTIME(tr.`tr_last_update`, '%e') AS 'Day',
COUNT(tr.tr_id_pk) AS 'Record Count'
FROM records_table AS tr
GROUP BY FROM_UNIXTIME(tr.`tr_last_update`,'%e')
) AS q1
ORDER BY 'Days of month';
Days of month Record count rt
10 13 13
11 2 15
7 255 270
8 173 443
9 166 609
It’s being treated as a string. Try casting to an int: