我编写以下MySQL命令来获取学生的分数总和并对其进行相应排名。
SELECT student_id, thescore, @rownum:=@rownum + 1 AS rankstudent
FROM
(
SELECT student_id, SUM(score) AS thescore
FROM school_ranking
WHERE school like '%Standard6%' and student_id <> ''
GROUP BY student_id
ORDER BY thescore DESC
) Sub1
CROSS JOIN (SELECT @rownum:=0) Sub2
结果如下:
student_id thescore rankstudent
J007766 5739 1
J007625 5159 2
J007629 5158 3
J007713 4460 4
J007690 4384 5
我的问题是如何获得特定学生的排名? 例如,如何获得ID为&#39; J007625&#39;
的学生的等级?答案 0 :(得分:0)
class Something {
public:
void start() {
this->task_ = std::thread(&Something::someTask, this);
this->isRunning_ = true;
this->task_.detach(); // I read detach will stop it from hanging
}
void stop() {
this->isRunning = false;
}
~Something() {
this->stop();
}
private:
std::atomic<bool> isRunning_;
std::thread task_;
void someTask()
{
while(this->isRunning_) {
// do something forever
}
}
};
Something whatever;
whatever.start();