How to find nth heights salary in employee record?
How to find heights value as required?
How to find 10th heights value as given entity?
How to Use Inner Query?
How to use while more than ones?
SELECT DISTINCT(A.EMP_SALARY) FROM EMPLOYEE A
WHERE &SALARY = (SELECT COUNT(DISTINCT(B.EMP_SALARY)) FROM EMPLOYEE B
Inner Query :
SELECT COUNT(DISTINCT(B.EMP_SALARY)) FROM EMPLOYEE B WHERE A.EMP_SALARY<=B.EMP_SALARY
The query you have mentioned is a co-related subquery which means for each record from outerquery,
the inner query will be executed and returns its output.
Consider you want to display 3rd highest salary, so &SALARY = 10
Inner query will return the number of distinct salary records in the table which matches A.emp_salary <= B.emp_salary. If the count matches with 10 then your query will return that salary record.