0
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);

错误:组功能的使用无效

为什么?

谢谢。

4

1 回答 1

4

您不能在 where 子句中使用聚合。这就是“拥有”的意义所在。

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)
group by a.nume,m.model
having sum(km_sosire-km_plecare)>100
order by sum(km_sosire-km_plecare);
于 2010-01-16T12:00:36.750 回答