GATE | GATE CS Mock 2018 | Set 2 | Question 61

Consider the following tables :

2

What will be the output of following SQL query ?

SELECT * FROM EMPLOYEE E    
WHERE 2 = (SELECT COUNT(DISTINCT E1.SALARY)    
FROM EMPLOYEE E1    
WHERE E1.SALARY>E.SALARY) 

(A) Second highest salary
(B) Two distinct salary of employees
(C) Third highest salary
(D) Employee with second highest salary


Answer: (C)

Explanation: Query will give the 3rd highest salary. N-1 = 3-1 = 2
Can be used to find for any value of n.

Quiz of this Question



My Personal Notes arrow_drop_up


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.