mysql在考试中获得学生排名(mysql get student rank in exam)
我有以下查询。
SELECT SUM( marks_obtained_written + marks_obtained_oral + marks_obtained_classwork ), FIND_IN_SET( SUM( marks_obtained_written + marks_obtained_oral + marks_obtained_classwork ), (SELECT GROUP_CONCAT(summarks ORDER BY summarks DESC) FROM (SELECT SUM( marks_obtained_written + marks_obtained_oral + marks_obtained_classwork ) AS summarks FROM results GROUP BY student_id) sm) ) AS rank FROM results WHERE student_id = ".$student_id." AND exam_year = ".$year." AND exam_id = ".$exam." AND results.class_id = ".$class_id." AND section_id = ".$section_id."
只有在我的结果表中有一个考试时,此查询才适用于我。 当有更多考试时,此查询会计算所有考试的分数并返回给我。 但是如果我只需要一个考试的学生排名,我需要在查询中放入exam_id,当我这样做时,查询返回0作为学生排名。
在上面的图片中,我得到了第0个无效的位置。但是如果我删除了exam_id条件,那么我得到了正确的等级,但问题是所有输入的考试的总和标记,我不想要因为我需要特定考试的等级。
所以请任何人告诉我应该在我的查询中放置exam_id条件。
I have the following query.
SELECT SUM( marks_obtained_written + marks_obtained_oral + marks_obtained_classwork ), FIND_IN_SET( SUM( marks_obtained_written + marks_obtained_oral + marks_obtained_classwork ), (SELECT GROUP_CONCAT(summarks ORDER BY summarks DESC) FROM (SELECT SUM( marks_obtained_written + marks_obtained_oral + marks_obtained_classwork ) AS summarks FROM results GROUP BY student_id) sm) ) AS rank FROM results WHERE student_id = ".$student_id." AND exam_year = ".$year." AND exam_id = ".$exam." AND results.class_id = ".$class_id." AND section_id = ".$section_id."
This query works fine for me only when there in one exam in my result table. When there are more exams,this query calculates marks for all exams and return rank to me. But In case I need student rank for only one exam, I need to put exam_id in the query and when I do that, the query returns 0 as student rank.
In above picture, I got 0th position which is invalid.But if i remove the exam_id condition,then I get the correct rank,but the problem is it sums marks for all entered exams which i dont want as I need rank for a specific exam.
So please anyone tell me where should I put the exam_id condition in my query.
原文:https://stackoverflow.com/questions/43178310
最满意答案
我真的找到答案。 我认为它更多的是一种解决方法,而不是一种解决方案,但它到底是什么。
我试图调试整个Dockerfile(一个接一个地注释掉一个命令),直到只剩下FROM和MAINTAINER。 我仍遇到同样的问题。
所以我将FROM图像更改为另一个图像,问题解决了。 基础图像超过9个月大,可能建立在一些旧版本之上,我不知道。
此处的解决方法只是更改FROM映像或(如果您有访问权限)重建它。
干杯!
I actually found answer. I think its more of a workaround than a solution, but what the hell.
I tried to debug the whole Dockerfile (commenting out one command after each other) till the point where I was left only with FROM and MAINTAINER. I was still running into the same issue.
So I changed FROM image to another and the problem was solved. The base image was more than 9 months old and probably built on some old version or something, I do not know.
The workaround here is just to change the FROM image or (if you have access) rebuild it.
Cheers!
相关问答
更多-
尝试改变 RUN ["./gradlew", "clean", "build", "--debug"] 至 RUN gradlew clean build --debug 对于RUN命令,不需要添加[,] 。 主要针对CMD, ENTRYPOINT 解决此问题的一般解决方案是进入系统进行调试 对于这种情况。 Removing intermediate container 02b237aa04c0 Step 3/4 : WORKDIR /app ---> e238b49f5174 <== useful ...
-
此问题也在docker hub论坛上报告,并由docker hub团队解决。 标签现在正常显示。 https://hub.docker.com/r/stakater/base/tags/ The issue was reported on docker hub forum also, and it is resolved by docker hub team. The tags are showing properly now. https://hub.docker.com/r/stakater/base/ ...
-
您可以直接使用Azure容器注册表webhooks ,简单的工作流程: 构建一个Web Api项目,通过Queue a build Rest API对每个详细请求(webhook请求)进行排队 创建Azure容器注册表webhook以调用Web API(步骤1) I choose option three. Therefore I set up a github repository with a one line Dockerfile: FROM alpine I used the alpine ima ...
-
简短回答:配置书签名称就好像它们是标签一样,它应该可以工作。 较长的回答:从一些实验来看,截至2016年9月,似乎书签名称实际上与Docker Hub中配置的标签和分支版本相匹配。 但是,在推送书签更新时,只会自动触发与名称匹配的标记构建; 分支构建不会自动触发,但仍可以手动触发。 Short answer: Configure the bookmark names as if they were tags, and it should work. Longer answer: From some expe ...
-
我已经联系了他们的支持团队,根据他们的回应,目前对自动构建的限制是: 2小时 2 GB RAM 1个CPU 30 GB磁盘空间 因此,对于较大的构建,您必须将它们分成由FROM语句和Repository Links连接的多个Automated Builds,或者在您的机器本地构建它们并将它们推送到存储库。 I've contacted their support team, and according to their response, the current limits on Automated Bu ...
-
在错误输出中,它列出了ext_name的可能值。 mysql未列出。 有mysqli和pdo_mysql ,但不是mysql 。 你的命令确实包含了mysql ,错误的第一行似乎在抱怨。 尝试解决这个问题,看看是否有效。 In the error output, it lists the possible values for ext_name. mysql isn't listed. There is mysqli and pdo_mysql, but not mysql. Your command do ...
-
如何在Docker Hub中从源代码构建Emacs?(how to build Emacs from source in Docker Hub? gap between BSS and heap)[2023-11-10]
因为你是crosspost,我crossanswer:P恕我直言交叉错误,你应该删除其中一个问题。 这个问题也在这里得到解答(因为你已经找到了我的github bug报告): https://debbugs.gnu.org/cgi/bugreport.cgi?bug=23529 目前,在emacs构建系统发生变化之前,可能会出现这种情况,唯一有效的解决方案是: 不要使用Dockerfile构建并构建一个运行容器,该容器具有允许个性系统调用的seccomp配置文件。 例如: docker run --rm - ... -
您不必将postgres二进制文件和数据放在同一个容器中。 pg_config基本上是配置你的postgres。 pg_config在postgresql-devel (Debian / Ubuntu中的libpq-dev ) 在本质上: # container were your data is docker run -d --name openproject-postgres-data -v /data busybox true # container were postgres runs docker ...
-
Docker Hub上的自动构建中的“例外:非零退出代码:1”(“Exception: Non-zero exit code: 1” in Automated Build on Docker Hub)[2023-08-25]
我真的找到答案。 我认为它更多的是一种解决方法,而不是一种解决方案,但它到底是什么。 我试图调试整个Dockerfile(一个接一个地注释掉一个命令),直到只剩下FROM和MAINTAINER。 我仍遇到同样的问题。 所以我将FROM图像更改为另一个图像,问题解决了。 基础图像超过9个月大,可能建立在一些旧版本之上,我不知道。 此处的解决方法只是更改FROM映像或(如果您有访问权限)重建它。 干杯! I actually found answer. I think its more of a workaro ... -
我终于弄明白了。 这个问题与这个问题有关。 我在我的主机中使用Docker 1.0,但后来的版本在Docker Hub中正在生产中。 如果Dockerfile中没有明确的ENV HOME=...行,则版本1.0使用/作为主目录,而/root用于更高版本。 结果是vim无法找到它的.vimrc文件,因为它被复制到/而不是/root 。 我使用的解决方案是在我的Dockerfile中明确定义ENV HOME=/root ,因此两个版本之间没有区别。 I finally figured it out. The i ...