sql报错 Aggregate expression is illegal in WHERE clause

select f4,... from tb1 where f1=1 and f2=2 and max(f3)=5 group by f4; -- 报错 Aggregate expression is illegal in WHERE clause
select f4,... from tb1 where f1=1 and f2=2 group by f4 having max(f3)=5; -- success