聚集函数
avg() 函数
select avg(prod_price) as junjia from products; // 求平均值
count() 函数
select count(prod_id) as chanpingnum from products; // 统计之和
max() 函数
select max(prod_price) from products; // 找出最大值 select max(prod_price) from products where left(prod_name,1) = 's';
min() 函数
select min(prod_price) from products where left(prod_name,1) = 's'; // 找出最小值
sum() 函数
select sum(quantity) from orderitem;
聚集不同的值
select avg(distinct prod_price) avg_price from products;
组合聚集函数
select avg(prod_price) avg_price,max(prod_price) max_price,min(prod_price) min_price from products;