select nume,model,sum(km_sosire-km_plecare) as 'km_parcursi' from masina m
inner join (foaie_parcurs f inner join angajat a using(id_angajat)) using(id_masina)
where sum(km_sosire-km_plecare)>100
group by a.nume,m.model
order by sum(km_sosire-km_plecare);
Error: Invalid use of group function
Why?
Thanks.