「SQL」having文で集約関数の値に条件を指定する

2021年8月22日

書式
select カラム名 from テーブル名
group by カラム名
having 条件式
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
select
productname
, avg(price)
from
products
group by
productname
having
avg(price) > 100
select productname , avg(price) from products group by productname having avg(price) > 100
select
    productname
    , avg(price) 
from
    products 
group by
    productname 
having
    avg(price) > 100

結果

ProductName AVG(price)
Côte de Blaye 263.5

SQL

Posted by arkgame