「SQL」group byで指定項目の複数の行をグループごとに表示する
書式
select 項目名 from テーブル名
group by 項目名
使用例
select
productname
, avg(price)
from
products
group by
productname;
select
productname
, avg(price)
from
products
group by
productname;
select productname , avg(price) from products group by productname;
結果
ProductName | AVG(price) |
---|---|
Alice Mutton | 39 |
Aniseed Syrup | 10 |