Open In App

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

Like Article
Like
Save
Share
Report

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


Last Updated : 08 Mar, 2018
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads