分組返回數據,不是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