不能直接使用新的字段名,可以在HAVING子句中以聚合函数作为条件。
如:
select sum(score.绩点*course.学分)/sum(course.学分) as 平均绩点,fieldn from tablename group by fieldn having
sum(score.绩点*course.学分)/sum(course.学分)>300
如果非要使用新字段名也可以,要把分组查询结果作为子查询。
如:
select * from
(
select sum(score.绩点*course.学分)/sum(course.学分) as 平均绩点,fieldn from tablename group by fieldn
) a
where 平均绩点>300
不能直接使用新的
字段名
,可以在HAVING子句中以
聚合函数
作为条件。
如:
select
sum(score.
绩点
*course.学分)/sum(course.学分)
as
平均绩点
,fieldn
from
tablename
group
by
fieldn
having
sum(score.绩点*course.学分)/sum(course.学分)>300
如果非要使用新字段名也可以,要把分组查询结果作为
子查询
。
如:
select
*
from
(
select
sum(score.绩点*course.学分)/sum(course.学分)
as
平均绩点,fieldn
from
tablename
group
by
fieldn
)
a
where
平均绩点>300
select * from (select sum(score.绩点*course.学分)/sum(course.学分) as 平均绩点 from tablename) a where 平均绩点<2.2