Write a SQL query to find the 7th highest employee salary from an Employee Table. If that employee is male, shift to the next employee in alphabetical order. Explain your answer.
SEELCT Employee Name , Gender ,CASE WHEN Gender =’Female’ then (Select salary from employees table order by Salary DESC limit n-1,1)ElSE (Select salary from employees table ,order by Salary DESC ,limit n+1,1) END as Salary
FROM Employees Table ;
Answer ( 1 )
SEELCT Employee Name , Gender ,CASE WHEN Gender =’Female’ then (Select salary from employees table order by Salary DESC limit n-1,1)ElSE (Select salary from employees table ,order by Salary DESC ,limit n+1,1) END as Salary
FROM Employees Table ;