Home [SQL] 取得最大值的列
Post
Cancel

[SQL] 取得最大值的列

範例

1
2
3
4
--由商品清單取得持有最高販賣單價的商品
select * 
from 商品清單
where 販賣單價 = (select max(販賣單價) from 商品清單)

執行結果:

1
2
商品ID	商品名稱	群組名稱	進貨單價	販賣單價
2	筆記型電腦	電腦主機	299000	270000
This post is licensed under CC BY 4.0 by the author.