mysql添加为成绩表添加名次
对于一种这样的表,为score添加名次
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC8AAACbCAIAAAB9HlWYAAADqklEQVR4nO3czW7TQBAA4HkeekSWgl8hDxGph5X6FhzAlbjEr1BObU65YFQSTpxA5NTevDcECKVES3+S0joOh43j9axtqqjrcdQZzaVVIn3adZqZ3VFhZYSU8ttiRZVSSmANax5Pcx4+B//lufWeoYBO+Olpa6rStWZxe6czSZZSyo+/V3V5IsAL39a/Ztus1nwN90Acrl8XdcEIp5r54q/OCk3UBeierN9w2GtWM75Ixxfp+Et/D0RwkY6PBXj9I/1L+8dHzYJmuWyB5mZ+qzNZLqWUo2k6mqajz/1nIF5P09H0XRege5yOpuloGh94AF7/SL/msfMhmnR0LLIH+MXBK+FWc32z0Kmfmw+zJVVKKeHqeq5zrfmxpMoSzemvhCqllHB5daMzSRIp5en3hCqllPDn8lrnfZJIKd//vKfK9mlkmwLQd/qKLpRSrGENa7aJSACAiOg1cegD+EL4FRpUmTrW5KZyDQC0S7MBtUJj1snEGlS1E2tQnfykNHHom110waSUAlS1O9bUhVIKUNVOrEFVO7WmWLUTa1CdzBpDg6p2RRr4FJJqYVZ6bcyfWZMHa6qDNca3OCoqmtdEwg/jnFXwKKXwyb5jjRlx6G9o9JpI2GuDTvabtBRWhlATiZLWt6DR9wxUlLUGnew7lsShjzeIThOJQscA1mcK3TO41dSGUgqf7LPG0KB7BmINOtlnjaFpdc8wowvWsIY1W8Wgt/4C7w2oNZPAWyMGPexRdpXuWGPEoAdeMGmJxsLMlF2lO1dMAq/0qaHRZDHoQclOoZ6hMY29V8qu0t0C8o/UbBJ4JWvTqCZ/bCr+3qCewbWmJpRdpbPG0KCegViDqnTWGJpW9wwPbX4cBGuqgzXVwRodeirIPi+m0MSh7/vW4agiOdnX9wvlZ+lNa7K7jjac7OfXQPQa80rqPxr39wx4+Abd36nG7xnyKF+bdmn4nmFXNHzPsCsa7hnKgzXVwZrqePKawrRA8UucRlM3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EV8pdycD4vEKD2+A91qCr17yNsyCeTlFmODWXY5iZpCUhzPQMsXeEikScAe38Ug52cxyGd2vae3DRAkW+ksS5iMh9F4+cSZBNTk/3RIeLWUdv0tk6ARJNnlJAoma3mnpff0tcGCRLRi92Rcg9WYL/dxIJoLkiaFIFr2J50YcSy3+KNhPJCP8vWenjaYkEh7NAkM7fhQmF8mgbSDQzOTAIAkk86dq0tVZXDoczS0Wbu9FHr3ULT1ODSdZRFfnqhLX2U5YPxCzHtzQdKkWopf6/Jd/ZQItJMk3cQBV0Nh3gVJk0IQUOJbORlv6elpQzHOUJvvAyTnQ3Uxpvf0uKEYZ6jNuyBpUi2F4uu9oY4DCvMuSJoUgqD4em+o44DCPEGCvqGOAwrzLkioWgqJxGWFJCORSJoIEhKpRgQJiVQjgoREqhFBQiLViCAhkWpEkJBINSJISKQa/R9TgnqRWEVF6QAAAABJRU5ErkJggg==" alt="" />
对于mysql来说
名次用临时变量来保存,考虑对于相同的分数名次一样,可以先将表按分数分组,与名次单独查询出来
select @counter:=@counter+1 as rank,t.score from (select @counter:=0,score from user group by score order by score desc)as t
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKQAAAB1CAIAAABPtd2cAAAHNElEQVR4nO2dzW7bRhCA53nsMwGar6BHKBABskHAfooeYhVQVJiPkORk62IpQFSkdh4ggXVpbF+4t6ItCjmCktiyUktiD+SSy5+lSJlcDuP5sAdxTDq785GUFI1H4DjOy5cvnXUwxv68d2oxGGNrl4OWUicPDsnGBMkm2cVAsnFBskl2MaiUbf+sw099kp0GySbZxUCycaFC9v38v5SxWCwZY+8/O48b9oEGjZNH/pL1gzGWvhy0w80zKtmus2EDADTr9Wfn/YW1DR7c5bABxsGh6Qa3D+2obPeQ5rBs2ZfdHT61vb4XfLPLQ3r3OhIRdrt+ocPu4M0uAOi/XiYfWE/Zs/vvKSMuG8D8xd9sWq/dxycmjw8bvssLaxuMgwtB9okJXqSsK9ub+WVXh71+aC2DFoD+4loa6e+Bd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ZuUgkh0tSjEsWxLkYJYdrqfCAWLZOMqSNmuzGLsJoQCRbNsyxDs2+HXjsSAHqezYHzNgAZFsJ/SHPpb/Yicx6DgOBtnxnppoTTvYZAckPuVFgypk52mzKPypEkpwyk58yosHkcn2b0GSd4qVg0l2znfZamRX21OzWDDJzo0K2dW2WSwWki2DZONChexqe2oWC8mWkaOdZXmTKBaSLYNk40KFbKouxUPpstfuxxib1ITpdFr1FDaHZOeDZJPsekCy80GySXY9INn5INnFyu41vY9tmr3K0iIFl+xRm3+hodYe+VE/gWJwMsEne9TWPMe9JkbdmGQLGeo1udlRW+MPYxlUITtLwWHyWqKnZvUgkh3Kz6itae2R69oXHNqYYJaN0jVm2dDsTSa9pqg3kkMVsrMUHAZr4M9D+G7hkwkq2aO2Jt7GAZq96LWMXrYwUYSXNiLZk9BLsXZTa4/QX9ludalkKehs45IdwCUn3ts5KmRnKTgMpsdnJ7ysRARO2YJiQXDsYkEmW3zriPJZG5Ps5HfZQjiaQBWys1SXqk3T5mCSnRsVsrMUHFadh6yQbJJdD1TIzlJdWnUeskKy18jOUnBYdR6yQrJJdj1QIZuqS/FQuuy1+1HduBpIdj5ItgySjQuSnQ+SLYNk44Jk54Nky3iEbPfbwbF1VEEmO9SBJkiW0BsLd+9SF9syDANl2yRssmMpEtpNxVqMqZCdt52l23KTOhyuJSFFaV+xjVB2YstVNGCTHe3WXfn3Z+dpZxmcjCQ7O/69O3Ito5YtzpVk54FnC/mVLfYujXxLNMJvE6iB7GpbUOfpXRqfPi4wyR6awl2QJ0sQXMk3CZDsskh8Rx10L43eFVXIpt6lSFAhm9pZIoFk54Nky6DepbhQIZvaWSKBZOeDZMug6lJ0lC67vH+AwAPJfkKQ7CcEyX5CkOwnBMl+QpDsJ8T/4PfQaWPUZdMAAAAASUVORK5CYII=" alt="" />
然后将该表与原表关联,为每个人添加名次
合起来的一句sql就是
select u.id,u.username,u.score,a.rank as 名次 from user u,
(select @counter:=@counter+1 as rank,t.score from (select @counter:=0,score from user group by score order by score desc)as t)a
where u.score=a.score;
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQ4AAAClCAIAAAAif4RrAAAQ+klEQVR4nO2dz2/jxhXH5+9pjoEKmv/C/ge9CJAMAvkr0kOrYGUtlpc95LbpKXGArrRAFSR2DkFPLeou1pJ9ERFgESRB4I3gxrbs7NpmD8Mfw5khh7ZFznuj98UcpBElffnefDhDSXxi5+fnhwD0ePQsBqnHo2e2Y3N4eHh4fn7+ePTs8eiZ9XxxJ6ebJ3Z2dvYagCCjYjs2r1+/fn12dsZRsZ4v7sT2uLUgdnZ29gqAIKNiOzavXr16JaICwYntcWtBjCcAQrMNhV7Ww0INSGO2hyKJhEOEColUS4QKiVRLLI7j5yQSyaQEFSNSURT9cBnbalEUNX7QwCDUcUBhvsIkoYJJqOOAwjyh4ohQxwGFeULFEaGOAwrzhIojQh0HFObXiso8/JD5f54rA3ocMC/8J6HSpFDHQWd+GjA/XJifuwj9YNqAJ0WEiiNCHQfF/DRgGiXoTAOBodZIaWcBRqg0L9RxEM0vQp8xJg//RegLfOQzjo6phtAxo3J59a6iXV/fRFH07a9xVfsiYJ3wb9Xb3LdFUVTtcBMaz4J1Gw83Px9tMe/J/OrduL+1c5RuM9nmncKzjne87fHV8Y4nbJb3N2Vyfaj8J/yABZ8kg3j6SCS9BVSOnngsDZNwez7aSk1kQXzZT7u80XEaYtafvOwzxrwn86uXfba1M9oubsNfNlF/kr3U1s4k6e9P3l1OlGdp3q7B0VZ7l/MeYTMpDhbMi0HrT96N+4z1X+qfO9lOHjp64nlP5lfv5qOtRk0aUFld/l7RSlCZPmLs0RfJaP6k2ywqiZn5yGPbY+m22Jm0SY95wzm/fTz0WG+c3GD5lpMeY6w/SV+Kb3887I9mfIPxdrrxpMcY80azpFN8VraB+nZrbjwLmjgIu+PtHJf25LujxqFd80Kb7XiMlb7juJ8Z+3013k5S0FhbGyr7b2/3397u//vpBywYvL3d/zxgnaef8U717lqbARU+lFkxrEV5O8fKO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EBRhj3XF8MPTropKe50DLlxmV/be3vEmcZP1toCKcqHz8fWFiEaI87Sbni9NuMterPc42QKisEkIYY8wLBz1/MLvnrAJqIXBPVLLONlD5Mn5TC5X4YOh3hgvxAKb2uNpgoZK39CClXZUZzGdHOhDNjMreyS1vGSdZD2/tnNYneFQswFbxchZ2vKDrCfFVexxtMFERZg8BD+W8MTc/CzvCYQ7ZrCKhInHSDioffhp/l9pKTlq0qOhmbWjzeHOJtO4hbYuBlxxVC+fl+Zct8mJYWhqwks2sR9iAyjfLG94YY9ltsYH6tl792ATaBynNJdK6B7fN10Dlp5vqBgiVwof3JT2ONhSjDbV5Mypf/3Jd3YCgstuTP2FUexxuKEYbavM1UPnxuroBQWXDG+o4oDBvRuWrn99XN0IFQkMdBxTmCRVHGuo4oDBvRoUqtpBIXAZUyh4mkUhchAqJVEuEColUS/8HHJ/MPFX9J90AAAAASUVORK5CYII=" alt="" />
mysql添加为成绩表添加名次的更多相关文章
- java+ mysql 给所有的表添加假数据
需求:别的项目, 代码扣过来了, 数据库也拿过来了, 但是数据库全是空表, 一共700 张表,需求是给表添加假数据,让它能运行起来. 一下是代码实现: 1.数据库连接: public static C ...
- mysql 如何给大表添加字段
1. 能不加字段就不要加, 能不修改字段就不要修改, 能不删除字段就不要删除, 等等为什么要删除字段呢? 如果没事,不要蛋疼的找事. 实际上,我们那次更新失败后, 我们并没有增加那个字段, 然后我们一 ...
- MySql给表添加列和注释
1.给表添加列 ALTER TABLE supplier_seller ADD COLUMN company_id INT NULL COMMENT '供应主体id'; 默认情况下,添加的列会添加到最 ...
- 给mysql一百万条数据的表添加索引
直接alter table add index 添加索引,执行一个小时没反应,并且会导致锁表:故放弃该办法,最终解决办法如下: 一.打开mysql 命令行客户端 这里我们那可以看到导出的数据文件所存放 ...
- MYSQL如何在创建表时添加判断条件
大家好,我是小皓. 一.背景 今天在博主练习MYS创建表操作时遇到一个语法报错,就想着来和大家分享一下MYSQL如何在创建表时添加判断条件: ERROR 1064 (42000): You have ...
- 【MySQL】实现线上千万数据表添加字段操作以及缓存刷新
需求背景: 由于业务需求,需要在线上用户表添加渠道字段,用于区分不同渠道注册的用户,目前该表有20+个字段,8个索引 线上用户数据大概1500W左右,需要不停机增加数据库字段,同时需要刷新Redis缓 ...
- JS-DOM 综合练习-动态添加删除班级成绩表
费了2个小时,才把原理弄懂,把问题逐个解决,当你发现你最后栽的那个点,是一个小石头拌的你,你起来是该哭还是该笑呢?只怪自己习武不精吧. 虽然问题都解决了,但是还有一个余留的问题就是鼠标经过input时 ...
- mysql经典面试题之学生成绩表
需要数据库表1.学生表 Student(SID,Sname,Sage,Ssex) --SID 学生编号,Sname 学生姓名,Sage 出生年月,Ssex 学生性别 2.课程表 Course(CID, ...
- Oracle数据库建表+添加数据练习
SQL脚本: --建表 --student表+注释 create table student( sno ) not null, sname ) not null, ssex ) not null, s ...
随机推荐
- JAVA学习:多态
多态:可以理解为事物存在的多种体现形态. 人:男人,女人 动物:猫,狗. 猫 x = new 猫(); 动物 x = new 猫() 1,多态的体现 父类的引用指向了自己的子类对象. 父类的引 ...
- 关于xml的一些操作
一些关于xml的资料: 创建一个xml static void CreateFile() { ; Random random = new Random(); using (XmlTextWriter ...
- Android简单发送邮件(可带附件)
项目中遇到了一个发送邮件的功能,在网上查了很多,资料也很多.这里就不一一介绍了,只是写出我使用的方案(最简单的) Intent email = new Intent(android.content.I ...
- Nginx 配置基于域名的虚拟
编辑配置文件 vi /etc/nginx/nginx.conf user www www; worker_processes 2; error_log logs/error.log not ...
- CF 161D Distance in Tree【树DP】
题目大意:给一棵树,求树上两点之间距离为K的点对数目. 方程含义: dp(i,j)表示从已经遍历过的点到当前点i,路径长度为 j 的路径条数.因此,对于当前点,每当遍历了其中一个儿子节点的时候,首先统 ...
- 如何在大型的并且有表分区的数据库中进行DBCC CHECKDB操作
如何在大型的并且有表分区的数据库中进行DBCC CHECKDB操作 其实这个问题已经在<SQLSERVER企业级平台管理实践>里徐老师已经讲过了,不过我想用自己的语言再讲详细一些 笔记链接 ...
- SystemTray文字颜色问题
今天想给SystemTray的ForegroundColor设置为白色,但是模拟器正确,真机仍为黑色.经过一番折腾,发现是微软做了限制,背景是什么颜色,ForegroundColor就不能为什么颜色. ...
- [每日一题] OCP1z0-047 :2013-07-26 alter table set unused之后各种情况处理
有疑问可以去itpub讨论:http://www.itpub.net/thread-1804872-1-1.html 对于alter table setunused的用法,查官方文档: alter_t ...
- PHP自学之路---雇员管理系统(2)
这个章节将讲解分层模式对雇员管理系统的系统,首先看下基本的流程图设计: 下面是具体的代码: 1.login.php(参照上节) 2.loginProcess.php <?php /** * * ...
- Fragment与Activity交互(使用Handler)
1.在Activity中定义一个方法用来设置Handler对象 public void setHandler(Handler handler) {mHandler = handler;} 2.在Fra ...