我目前正在做一项家庭作业,要求进行选择,以拉出包含与所有其他记录相比最大值的特定属性的元素.我在线阅读了一些引用称为"最大"的"聚合"关系代数函数,但它们没有描述它如何使用基本运算符.如何选择包含最大值的属性?
任何人都可以解释以下查询获得3个最高薪水吗?
select distinct sal
from emp a
where 3 >= (select count(distinct sal)
from emp b
where a.sal <= b.sal)
order by a.sal desc;
Run Code Online (Sandbox Code Playgroud)
有人建议我使用上面的查询来获得3个最大值.表中的工资.我不明白查询的下面部分发生了什么:
3>= (select count(distinct sal)
from emp b
where a.sal <= b.sal) ;
Run Code Online (Sandbox Code Playgroud)
有人能解释一下吗?如果还有其他方法可以得到相同的结果,请咨询我