统计函数:
count:统计行数
select count(t_id) from t97;
sum:统计合
select sun(t_id) from t97;
avg:求平均数
select avg(t_id) from t97;
max,min:
select max(t_id) from t97;
select min(t_id) from t97;
分组:
select count(*)from t_class troup by c_class; 查询每个班人数
select c_class,count(*) from t_class group by c_class;
having 是用于函数的过滤
select -- from -- where -- group by -- having -- order by -- limint
select count(distinct name) from test; 排除相同
mysql 运用union all (效率高,不排斥重复记录)union(效率相对低一些,过滤重复记录)进行排序的时候,最外层seelct * from(select ....union all select...)as aa order by。。。
Mysql 优化及配置(http://developer.51cto.com/art/201308/407931.htm)
mysql基础查询语句
猜你喜欢
转载自hwwlove.iteye.com/blog/1914869
今日推荐
周排行