Prima di tutto, non hai bisogno delle sottoquery, puoi invece fare un conteggio su una condizione.
Il with rollup
il modificatore può essere aggiunto al group by clausola per includere il totale generale. Il order by non può quindi essere utilizzato nella stessa query, ma può essere applicato in una query esterna.
Inoltre, con l'uso di coalesce puoi sostituire null valore per quella riga totale con l'etichetta di tua scelta.
Infine, per ordinare ancora la riga totale alla fine, puoi aggiungere un is null espressione in order by clausola, che restituirà false o true . Quest'ultimo viene ordinato per ultimo.
select coalesce(checkby, 'Total') as checkby_or_total,
fully,
faulty,
lasthour,
total
from (
select qcheck.checkby,
count(case result when 'fully tested & working' then 1 end) as fully,
count(case result when 'faulty' then 1 end) as faulty,
count(case when finishdate >= now()-interval 1 hour then 1 end) as lasthour,
count(*) as total
from qcheck
where date(finishdate) = CURDATE()
and qcheck.checkby not like 'michael'
and qcheck.checkby not like 'chaz'
group by qcheck.checkby with rollup
) as main
order by checkby is null,
total desc