SQL:查找(多个)教授的最佳学生按等级
必须
的 | 教授 | 中 |
---|---|---|
成绩 | 最佳 | 。 |
我 | 找到 | 每个 |
学生 | | |
| | |
| | |
| | |
| | 。 |
| | |
---|---|---|
| | |
| | |
| | |
| | |
SELECT Prof, Student, MIN(Grade)
FROM x
GROUP BY Prof
这样:
A | 学生 | 级 |
---|---|---|
A | 1 | 1.0 |
b | 3 | 1.2 |
... | ... | ... |
所以学生2-也是A教授最好的学生 - 失踪了。我该如何解决?
I have to find the students with the best grade of each professor with this given table "x":
Prof | Student | Grade |
---|---|---|
A | 1 | 1.0 |
A | 2 | 1.0 |
A | 5 | 5.0 |
A | 6 | 1.3 |
B | 3 | 1.2 |
B | 4 | 2.0 |
... | ... | ... |
The result should look like this:
Prof | Student | Grade |
---|---|---|
A | 1 | 1.0 |
A | 2 | 1.0 |
B | 3 | 1.2 |
... | ... | ... |
I already tried grouping the first table by Prof with:
SELECT Prof, Student, MIN(Grade)
FROM x
GROUP BY Prof
But the result gives me only one Student per professor like this:
Prof | Student | Grade |
---|---|---|
A | 1 | 1.0 |
B | 3 | 1.2 |
... | ... | ... |
So student 2 - who is also professor A's best student - is missing. How do I fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
就可以使用两种可能性
一旦选择了每个教授的最低成绩,
,并将TAT用作Resilset fpr in条款。或作为加入的桌子,大桌子上通常更快
You ave two possibilities
Once you select the minimum of grades for every professor and use tat as resilset fpr an IN clause.
Or as joined table, which is on big table usually faster