yes , you can't use aggregate function in where like that.it should be used in a sub-query for your solution/
here is how you can do it,
SELECT name, population
FROM countries
WHERE population > ( select AVG(population) FROM countries) ;
you also can populate the avg population in a variable:
declare @avgpop as decimal
select @avgpop= AVG(population) FROM countries;
SELECT name, population
FROM countries
WHERE population > @avgpop ;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…