www.5129.net > sql按照成绩排序

sql按照成绩排序

select 科目 ,avg(成绩) from 课程 group by 科目 order by agv(成绩)

Select Sno, GradeFrom scWhere Cno='c2'Order By Grade Desc

select 学号,成绩 from 学生表 where 学号 in (select top 10 学号 from 学生表 order by 学号 desc) order by 成绩

select id as 学号, sum(score) as 总成绩from 成绩表group by idorder by sum(score) desc, id asc

SELECT TOP 10 FROM 表名 ORDER BY 排序列 DESC;SQL的执行顺序先按照你的要求排序,然后才返回查询的内容.例如有一个名为ID自动增长的列,表中有100条数据,列的值得分别是1、2、3、4………9、99、100.那么查询加了DESC你得到的是91到100条,就是最后十条,如果加ASC你得到的将会是1到10,也就是最前面的那几条.降序用 desc 65条记录用top;如 select top 65 * from 表 order by 要按降序的字段 desc;select top 65 * from table order by id desc.

按照正规建表来说,这种状态的存储,应该尽量使用数字.比如:0未开始,1进行中,2已结束. 这样的话你只需要按照升序排列状态就可以了.数据库的大小也减少了.

SELECT 姓名,课程,成绩 FROM [表] WHERE 性别 = '男' ORDER BY 成绩 DESC SELECT 姓名,课程,成绩 FROM [表] WHERE 性别 = '女' AND 成绩 > 80 ORDER BY 成绩 DESC UPDATE TABLE [表] SET 成绩 = 90 WHERE 姓名 LIKE '张%'

select top 3 with ties name,score from record order by score(由低分到高分排列) select top 3 with ties name,score from record order by score desc(由高分到低分排列)with ties 的用法:对于TOP来说with ties 很重要,他能在显示的行后附加多个和最后一行取值相同的行.

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

with t as (select dense_rank() over(order by score) rk,stu_id,score from marks) select t.rk,t.stu_id,student.stu_name from t,student where t.stu_id = student.stu_id order by t.rk

网站地图

All rights reserved Powered by www.5129.net

copyright ©right 2010-2021。
www.5129.net内容来自网络,如有侵犯请联系客服。zhit325@qq.com