Prova questo SQL
SELECT * FROM
(
SELECT *, @total:= @total+ `companyearned` AS `total`
FROM `recordedhours`, (SELECT @total:=0) r WHERE `group` = '$uid'
ORDER BY `unixdate` ASC, `idnum` DESC
LIMIT $from, $max_results
) tab ORDER BY `unixdate` DESC