test 表
id epid name suject score
1 1 张小三 技术 89
2 1 张小三 理论 70
3 1 张小三 效率 79
4 2 李小四 技术 89
5 2 李小四 效率 30
6 2 李小四 理论 50
关键字
desc 降序
asc 升序
sum() 统计函数
计算每个员工的总分并排名(要求显示字段:姓名、总成绩) 降序
select sum(score), epid,name from test group by epid, name order by sum(score) desc select name as 姓名,sum(score) as 总成绩 from test group by epid order by sum(score) desc select name,sum(score) from test group by name order by sum(score) desc
计算每个员工的总分并排名(要求显示字段:工号、姓名、总成绩) 降序
select epid as 工号,name as 姓名,sum(score) as 总成绩 from test group by epid order by sum(score) desc
计算每个员工的总分并排名(要求显示字段:工号、姓名、总成绩) 升序
这块有点疑问?asc 为升序,为什么在中文姓名排序时变成了降序
select epid as 工号,name as 姓名,sum(score) as 总成绩 from test group by epid order by sum(score) asc
计算每个员工的总分并排名(要求显示字段:工号、姓名、总成绩) 按中文姓名首字排序 降序
select epid as 工号,name as 姓名,sum(score) as 总成绩 from test group by epid order by name asc
计算每个员工的总分并排名(要求显示字段:工号、姓名、总成绩) 按中文姓名首字排序 升序
需要了解更多数据库技术:SQL成绩统计排序实例教程,都可以关注数据库技术分享栏目—计算机技术网(www.ctvol.com)!
select epid as 工号,name as 姓名,sum(score) as 总成绩 from test group by epid order by name desc
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/dtteaching/625250.html