select *, sum(linea) as tot
from tabella
where pippo che ti pare
GROUP BY tot
ORDER BY ....