(Database) MySQL 中 MAX 和 ALL 的区别

AVG,SUM,COUNT,MIN,MAX 为 aggregation,只能应用于列数据上:

-- 选取各商品的均价
select AVG(price) from Products
group by prod_id;

ALL,ANY 则只能应用于一组被 Select 语句筛选出来的数据组:

-- 查找表1中商品,其价格需要高于表2中的所有商品
select prod_id from Products_1
where price > ALL(select price from Products_2)`

猜你喜欢

转载自blog.csdn.net/weixin_43728138/article/details/123693726