msql 统计函数 and 分组统计

Posted 王者之笔

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了msql 统计函数 and 分组统计相关的知识,希望对你有一定的参考价值。

 平均数

select  avg(shop_price) from goods;

求最大最小

select min(shop_price) from goods;

select max(shop_price) from goods;

求行数

select count(*) from goods;

 

分组统计

group 是需要耗费资源的  会有排序

slect cat_id,avg(shop_price) from goods group by cat_id;

select cat_id,count(*) from goods group by cat_id;

select cat_id,max(good_price)) from goods group by cat_id;

 

以上是关于msql 统计函数 and 分组统计的主要内容,如果未能解决你的问题,请参考以下文章