select b.group_id from a,b where a.group_id = b.group_id and a.flag = '2' group by b.group_id having count(b.group_id) > 10;