mysql成绩排名
关于mysql成绩排名,网上大部分只是order by简单排序,忽略了成绩相同并列名次的问题。
定义了一个表score结构为:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAboAAABuCAIAAADeTUFfAAAOjElEQVR4nO2dvbKjuBaF9U5dBLzKRERUTdBv0eXUnU42ObmjCe7NOuhy2oFngqnOTtDlU7e6U24gA1u/bIGEQKyvTlE+GBtYiKUtIW2Lvu/7vn9uxadPn37+/LnZ7kAUcNX4JNUq0Zd//vLrP3//b83f5y+/kh7hThAb2yUAYG98/vJr/V/uk9gC2CUAALCAXQIAAAvYJQAAsIBdAgAAC9glAACwYNnlnwAAcHq4dvk7AACcmwC77DORd+95+R6IvKi5jzoP0CoW5SkZ64zC7NK/WSLy7j0v379/55eJsREAraDVGspTMtYZwS53jbzMb29vb29v7+/v7+/vb24OUXDTAa1iUZ6Ssc4Idrlr6GWe5RAFNx3QKhblKRnrjM5tl/dLJarLnfxL/tsDOyy490slBpqOsfVWku5BqzBx9kocJakWq9XoGqET8o0Rzuh+qaoL7FJMhgm7nEOtX7pmttCeyS6DxYm446giR7PL6ajul8qhRtjBd80iUWGXMbhfqupyGa/AXu2S+TgvvV2GC7S5XebTKl/pSWOXa5XUjsp1kBva5aozgl2+LtV4wYYXNPJvOrm+aSohhKgu3eX14v76hteGSW4V7TK37VfzL6UFqHhKvNZAog2xUduUQj2za8UUx1WW+GVsqOOHLx3ejqdrHCV1QV5Op95cysHr952FyS5p9N41omqaUUDz0xHOCHZJ/XGwRbXMjX46llRSZO/0A2liC7NW/PChpX+sej4W9nOc2lnDK9Ly6hqxiVDP7FoxxXGVJX4Zu18qobaH0keXS5TUj8o4Ss/BO8+IRJeTtF3zMl5Sv6iGGeGMYJfkqnSNFmbS4MgIP2nBJcS3AXmZ/1GpB7T1eeySrjRvgK2EembXKlQcsywxy1jnFTwGcZR0RJfOm8t8y3JoSmN8ildlPaR8j+KXEc4IdqnX3E1TVZf7EBFNG/iKctrefOtlllfaXJmn75J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5rsf+4IwUZ98lraddZcxb9rRSM3qluR+uXeqfUe8R6xkNLLNLmRd4YhcJ3JZbgFqlOO7wVwtj9xZgBVpx4EeO8EofobbItkvqlX3f2/ouF9jl9GX+/qLHtV47kChDdDlp9rjWNMBRxXPXJFMzwWwgaEkhFUFv7asO2nUDU6/noZUbf3TpDy3REqcYpU59hm2UKL5dTkX11up2Nm32sJXsnlXOtXtkKMF62bi1QrQHtEu9a3bKCjU1FuvaWZNMH66JwuT7aJoptf5RhKWf2DHQajGh9ndmu1SgnTaaEWlvOSM+murNGHRplL9p2/6hPRnnlHNOCX3tSP7DNKyktji7d8ChvPkV6VgcXUbZviSCS13IAEndAiN9rZ8ks3o2AHYJNia0cX3yljgbGiAGtTWYLph2Vk+PBG7lgeiSD7SKRXlKro0u85I9oROWWGJ58iUSuJWGvK6AA7SKRXlKWs8IfZcAAMACdlka5dXz6YBWsShPSUSXAACwHNhlaZRXz6cDWsWiPCURXQIAwHJgl6VRXj2fDmgVi/KURHQJAADLgV2WRnn1fDqgVSzKUxLRJQAALAd2WRrl1fPpgFaxKE9JRJcAALAc2GVplFfPpwNaxaI8JddGl9vkarMCuwQAZAcJ3EpbSvZwJPtfQisoGXRGSOAGAAAs0HdZGrIaBBygVSzKU9J6RrBLAABgAbssjfLq+XRAq1iUpySiSwAAWA7ssjTKq+fTAa1iUZ6SiC4BAGA5sMvSKK+eTwe0ikV5SlrP6P9Evhf/JM/oGgAAAABJRU5ErkJggg==" alt="" />
mysql随数据库中意添加一些数据。
SELECT * FROM score;
查询结果为:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPoAAACYCAIAAABCsmM7AAAKO0lEQVR4nO2dP2/iSBjG/Z0ukZaWng+AtkCRwC39NddEKFWoT0qRFp2UJoLqFGn76KRIqaDZK1IhdDpFF8IuZK7wv7Fn7Nh4Zt4Z5vlpCpYk9vO+/jH+s4CD//7bYmDUHL86TkDeQQwMYwO6Y3g0glsAHIfVJvhXBbe3t0qWA8ARN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HfgEdAdeAS+eAN4hJrZHQAngO7AI6A78AjoDjwCugOPgO7AI6A78AjoDjwCugOPgO7AI6A78Ij/AYyzfILhwCxzAAAAAElFTkSuQmCC" alt="" />
我的解决方案:
SET @score = 0;
SET @sort = 1;
SET @num = 0; SELECT id, stundetNo, score, sort
FROM (
SELECT id, stundetNo, score, @num: = @num + 1, IF (score = @score, @sort, @sort: = @num) AS sort,
@score: = score
FROM score
ORDER BY score DESC
) AS t;
结果为:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOYAAACBCAIAAABb+VEOAAAIA0lEQVR4nO2dPU/jShSG/Z8uSOs2PT8AbYEiEf8IagoqXN+OFl2JjlS32X51JaRUpGELKoTQvWhBfERzi/hjPDNJbDJzzpzJ+2oK4g2e8555PB4be0/29PRf037/fkVDG9ROTk4UrTIgi7ZNOyEXkEUT1oAsmrDWQfYCgiLQgLXsxcXFv57kcVfQrmkwsl4u6zYeK4F0f3/P0q93sRvhCmBjv0A2UrEbAbJEYh9pX2I3AmSJxD7SvsRuBMgSiX2kfYndCJBdoXmZ5+XcS5dKKYJE+w54lYDsKtEia483F7Jf7nfNLzb/NC/zLGu/9aW+EkF2uPfIkLWVKrJ5UTTfA7Je+2WaZedlntUiQbbtMC/n+icNrSq8eZnnZVlUXyimxu/XAXf3qOx9Tovqlx2uq71ubUQpNa0jzYqp1UXrpf7YO+l9A1jX45D+NvXbiAXZaaGjQIDsvMzrDqdFm9m56gbQIJu1387cATc8unZV/1B9yXKthbOlEWNPVhe6F2fM2wawvsdkZlmbEi9dKqVWGl5ORdrgrke2z5ZM14rDQP91YyebmO1lxMie3YW5xYrZYwB2j3aEPQRkdWnp3h5ZO2zXPudlXpQeke0aGYrskFQPDiBlZOvT7XIDxVp2XhbGpVADjUZPFYxjmO2AtaWC7s44HpSqRtffwqBrpMfCoBvJ5kX0sADW99jPap9+NTFdftXXDJ2rHx9aezrrXAcsN+kn+SoY58xkB+y6gqz2aZhqgPdw+WUZ0cJYdfn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kOUaacmN3QhXAEBWamM3AmQTT3R6RoBs4olOzwiQTTzR6RkBsoknOj0jQDbxRKdnBMgmnuj0jADZxBOdnhFJyOKlcChmBZxlvewHggwBWUiYgCwkTEAWEiYgCwkTKbLTgqVub1vfulOlkL0aUH+1cWsFpFsb4XOqJY698hcdstMiy4uCuNbZmvrWcmrVaRXiuCqFtxXW+dNGhGyVdZbyfM5OKYsSbqtOecicBVlnMEyiQLZ1GQ2y/HPFMDXLAMfCgNQIP7EUyJoLSGpY7CxLmmKVamfUeZnb62/Koy+KI532jkEcs2wUie+vTvzO44/GTSxp2z1kpU2xyzWAWRecuFK4VqOcXYkja9W3jin3/WXf5KKtFG6s7XgTiD8lQMIEZCFhArKQMAFZSJiALCRMQBYSJiALCROQhYQJyELChJfCIWHCf70RaWM3whUAkJXa2I0A2cQTnZ4RIJt4otMzAmQTT3R6RnYbWdo609ZGrVI4YSQ+jayvFB6m+LoT2cuxVsM6mPEIkKWtM61/tCuFk0Xiz4irUnj44us2spfjbG882bUattTF7R+fV1UKllMQ1F0pvGmhSobbB//e2e3ulV0mMdyr0/CReDViVwpfhC6+rgdQ8Uo1gvEgS1Rn2tzonpminmINI9yVwpsqqrVCUhsPsnR1ps2NJrICeO0Y2VApPFTxdUcmHckM0m8EyNLWmV6XZcJI/BlxVAonKL6+08gS15nWPxqVwikj8WnEvskVvvj6TiPLNtKSG7sRrgCArNTGbgTIJp7o9IwA2cQTnZ4RIJt4otMzAmQTT3R6RoBs4olOzwiQTTzR6RkBsoknOj0jkpDFS+FQzOogyx0MBG0WkIWECchCwgRkIWECspAwAVlImIAsJExAFhImIAsJE5CFhOl/RjLlzlM8eNUAAAAASUVORK5CYII=" alt="" />
或者:
SELECT id, stundetNo, score, (
SELECT count(*) + 1
FROM score s
WHERE s.score > score.score
) sort
FROM score
结果为:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOQAAACGCAIAAABCCbGLAAAJwUlEQVR4nO2dzYsbRxrG+55/RPcZg3X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VskaAFbJGgBWyRoAVskaAFbJGfwK5qQ/FDt9p/wAAAABJRU5ErkJggg==" alt="" />
受到收到
mysql成绩排名的更多相关文章
- Mysql 查询实现成绩排名
Mysql 查询实现成绩排名,相同分数名次相同,类似于rank()函数 近日系统要实现总分成绩排名,而且相同分数的学生排名要一样,在网上搜了一圈,没有找到合适的方法,只能靠自己实现了,这里提供两种方法 ...
- mysql计算排名 转
from :http://www.cnblogs.com/aeiou/p/5719396.html http://www.cnblogs.com/zengguowang/p/5541431.html ...
- mysql计算排名
mysql计算排名,获取行号rowno 学生成绩表数据 SELECT * FROM table_score ORDER BY score DESC; 获取某个学生成绩排名并计算该学生和上一名学生成绩差 ...
- PAT乙级 1004. 成绩排名 (20)
1004. 成绩排名 (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 读入n名学生的姓名.学号.成绩,分 ...
- PAT-乙级-1004. 成绩排名 (20)
1004. 成绩排名 (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 读入n名学生的姓名.学号.成绩,分 ...
- PHP中通过sqlsrv调用存储过程——成绩排名去除重复字段的数据行
培训考试项目中,需要实现考试成绩排名:排名参考项为分数(score降序).参加日期(attendtime升序).第几次参加考试(frequency升序):并且,每个用户只保留一条数据(pid). 考试 ...
- 福州大学软件工程1916|W班 第6次作业成绩排名
作业链接 团队第三次-项目原型设计 评分细则 博客评分标准 在随笔开头,备注小组同学的学号.(1') 文字准确.样式清晰.图文并茂.字数在1000字左右.(10') 原型模型必须采用专用的原型模型设计 ...
- 福州大学软件工程1916|W班 第3次作业成绩排名
作业链接 结对第二次-文献摘要热词统计及进阶需求 评分细则 本次作业由三部分组成(程序满分80,博客满分70,工程能力满分30) 程序评分标准 基础需求 共有7个测试用例,每个满分20分并按照一定的映 ...
- 福州大学软件工程1816 | W班 第1次作业成绩排名
1.作业地址 第一次作业--准备篇 2.作业要求 (1)回想一下你初入大学时对计算机专业的畅想 当初你是如何做出选择计算机专业的决定的? 你认为过去两年中接触到的课程是否符合你对计算机专业的期待,为什 ...
随机推荐
- linux压缩解压文件
首先进入文件夹 cd /home/ftp2/1520/web 压缩方法一:压缩web下的888.com网站 zip -r 888.com.zip888.com 压缩方法二:将当前目录下的所有文件和文件 ...
- C(++) Websocket实现扫码二维码登录---GoEasy
最近在做一个扫码登录功能,为此我还在网上搜了一下关于微信的扫描登录的实现方式.当这个功能完成了后,我决定将整个实现思路整理出来,方便自己以后查看也方便其他有类似需求的程序猿些. 要实现扫码登录我们需要 ...
- 【Android Studio快捷键】之代码提示
接下来说如何设置代码自动提示,如图: 图上内容比较多,我直接按区域划分成6块区域来说吧: 区域1:这个选项是关于提示的时候如何进行匹配,即按照什么条件来进行提示内容的搜索. All:选择这个的话,意思 ...
- handler和Timer的用法
final Handler handler = new Handler(){public void handleMessage(Message msg){if (msg.what == 0x123){ ...
- 运用CADisplayLink来开启定时器
CADisplayLink来开启定时器 CADisplayLink是以屏幕刷新频率将内容绘制到屏幕上的定时器,每秒60Hz.使用的时候,先创建一个CADisplayLink对象,将其添加到一个RunL ...
- java 环境配置 及java 历史
知识点概括:1 Java 的历史 2 JDK 的配置 3 文件的编译与执行 ...
- UVa 673 平衡的括号
题意:给出包含"()"和"[]"的括号序列,判断是否合法. 用栈来完成,注意空串就行. #include<iostream> #include< ...
- ✡ leetcode 169. Majority Element 求出现次数最多的数 --------- java
Given an array of size n, find the majority element. The majority element is the element that appear ...
- Xcode LLDB Debug教程
开胃小菜--简单的断点调试 在xcode中打开一个app,在想要break的行号上单击,即可生成一个深色的箭头标识--断点.如下图,在viewDidLoad:中设置了断点. 运行app,等待...就可 ...
- POJ 3311 Hie with the Pie (状压DP)
dp[i][j][k] i代表此层用的状态序号 j上一层用的状态序号 k是层数&1(滚动数组) 标准流程 先预处理出所有合法数据存在status里 然后独立处理第一层 然后根据前一层的max推 ...