分组函数:group by
聚合函数 统计次数 count()
求最大值 max()
求最小值 min()
求平均值 avg()
求和 sum()
select uname,count(id) from sad where oid=1 group by id desc;
select uname,max(id) from sad;
select uname,avg(id) from sad;
select uname,min(id) from sad;
select uname,sum(id) from sad;
用LIMIT分页查询 函数 limit
select *from sad where uname like "研发部"group by time desc limit 3;
去除重复可以用分组和关键字 DISTINCT函数
select *from sad group by name
SELECT DISTINCT sex FROM student;