分组返回数据,不是where的那种返回特定数据sql
select vend_id, count(*) as num_prods from products group by vend_id;
按vend_id字段分组,而后统计总数返回数据spa
select cust_id, count(*) as orders from orders group by cust_id having count(*) >= 2;
筛选出须要数据code
where过滤行,having过滤分组blog