分組函數只要字段不帶有聚合函數的都要加入到group by 的後面進行分組
例select a b sum(c) from tablename group by ab;
如為單行查詢設置查詢條件(例如state_cd=MA)那樣也可以使用having子句為一組記錄設置查詢的條件例如假如只想了解客戶超過個的州使用having子句其查詢語句是
select state_cdavg(sales) from customer group by state_cd having count(state_cd) > ;
From:http://tw.wingwit.com/Article/program/Oracle/201311/18026.html