我正在尝试找到分数最低的学生,这将是以下查询的结果。但是,我被要求在不使用MIN()的情况下编写查询。花了几个小时,但我找不到替代解决方案:'(。
select s.sname
from student s
where s.score =
(select min(s2.score)
from score s2)
这是一种方法,即使两个学生的最低分数相同,它也将起作用。
SELECT distinct s1.sname
FROM student s1
LEFT JOIN student s2
ON s2.score < s1.score
WHERE s2.score IS NULL
以下是使用限制的方法,该方法将返回得分最低的学生,但是如果其中多个得分相同,则仅返回其中一个。
select sname
from student
order by score asc
limit 1
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句