Først og fremmest behøver du ikke underforespørgslerne, du kan i stedet regne med en betingelse.
with rollup
modifikator kan tilføjes til group by klausul for at inkludere totalen. order by kan da ikke bruges i den samme forespørgsel, men kan anvendes i en ydre forespørgsel.
Desuden med brug af coalesce du kan erstatte null værdi for den samlede række med den ønskede etiket.
Til sidst, for stadig at sortere den samlede række i slutningen, kan du tilføje en is null udtryk i order by klausul, som vil evaluere til false eller true . Sidstnævnte bestilles sidst.
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