📜  门| GATE CS Mock 2018年|问题19

📅  最后修改于: 2021-06-29 23:31:27             🧑  作者: Mango

考虑以下关系模式:

EmployeeDetail (EmpId, FullName, ManagerID, DateOfJoining)
EmployeeSalary (EmpID, Project, Salary)

考虑上述数据库中的以下关系查询:

SELECT Salary
FROM EmployeeSalary Emp1
WHERE 2 = (
                SELECT COUNT( DISTINCT ( Emp2.Salary ) )
                FROM EmployeeSalary Emp2
                WHERE Emp2.Salary > Emp1.Salary
            )

假定对应于上述架构的关系不为空。以下哪一项是对上述查询的正确解释?
(一)从表中找到最高薪水
(B)从表中找到第二高的薪水
(C)从表中找到第三高的薪水
(D)以上都不是答案: (C)
说明:对于第n个最高薪水-

SELECT Salary
FROM EmployeeSalary Emp1
WHERE n-1 = (
                SELECT COUNT( DISTINCT ( Emp2.Salary ) )
                FROM EmployeeSalary Emp2
                WHERE Emp2.Salary > Emp1.Salary
            )

选项(C)是正确的。
这个问题的测验