select * from empolyee GROUP BY age having count(*)>0;
select e.*,d.* ,count(e.employee_id) as num from empolyee as e, department as d
where age=24 and e.department_id=d.department_id
GROUP BY e.age having num>0;
having 对group by 分组进行筛选
如:对年龄分组后,对年龄的人数超过20人的进行筛选:
select e.* , count(employee_id) as num from empolyee as e GROUP BY age having num>20;