www.qnmk.net > 用SQL选出每个人成绩的最高纪录


select * from student where score > 80

分别倒序顺序排序取出5个 select top 5 * from 成绩表 order by 成绩 desc select top 5 * from 成绩表 order by 成绩 asc 一条语句就把他们连起来就好了 select * from (select top 5 * from 成绩表order by 成绩 desc) as a union all select ...

select name from student where stu_id not in(select distinct stu_id from score where grade < 80)

select t1.学号,t1.课程号,t1.成绩from table t1where t1.成绩 = ( select max(t2.成绩) from table t2 where t2.课程号 = t1.课程号 group by t2.课程号)

select top10 字段 from 表 where age between 18 and 25 and grade>100 order by province desc

select 学号,分数,* from 表 where 分数>'100' order by 分数 desc

用group by可以实现: select yhh,MAX(gdtime) from table1 group by yhh

各个数据库的方法并非一样Mysql: SELECT * FROM tbl LIMIT 0,100;SQL Server: SELECT * FROM tbl WHERE id IN (SELECT TOP 100 id FROM tbl);Oracle: SELECT * FROM tbl WHERE rownum

select username,max(uservalue) from table group by username 对人员进行分组,汇总每个人最大值,你自己根据实际情况改下了。


All rights reserved Powered by www.qnmk.net

copyright ©right 2010-2021。