索引与函数的关系:
1.存储过程
2,索引
3.触发器
4.多表查询
5.数据库函数
6.视图
5.数据库优化与效率
1,select class,count(*) from s_table where Score> (select avg(Score) as Score from s_table ) group by class ;
1,select c_Name,count(Score) from s_table group by C_Name
2.select C_Name,sum(score)as 数量之和 from s_table group by C_Name
group by于聚合函数如sum,max,min,avg,first,last,count之间的关系。使用这些聚合函数时需要group by的配合。
3.group by与order by的区别
首先order by id desc是按id降序排列,asc是按升序排列。而group by对数据进行分组,将数据划分若干个区域。
delete from s_table where C_Name not in (select max(C_Name) from s_table group by C_Name)
select * from s_table where C_Name in (select C_Name from s_table group by C_Name having count(C_Name)>1)
delete from s_table where C_Name in (select C_Name from s_table group by C_Name having count(C_Name)>1)