How do you retrieve the second highest salary from a table?
Answer Posted / hr@tgksolutions.com
Using a subquery:
SELECT MAX(salary)
FROM employees
WHERE salary < (SELECT MAX(salary) FROM employees);
Using ROW_NUMBER():
SELECT salary
FROM (
SELECT salary, ROW_NUMBER() OVER (ORDER BY salary DESC) AS row_num
FROM employees
) ranked
WHERE row_num = 2;
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
How do you delete a table?
What is a full join?
What are the operators used in select statements?
What is data definition language?
What is linq to sql?
Is it possible to create startup or shutdown trigger for on-schema?
How do I find duplicates in a single column in sql?
What is package in pl sql with an examples?
difference between anonymous blocks and sub-programs.
Could you please provide oca (oracle 10g) dumps for my certification ?
What is posting?
What is structural independence and why is it important?
How can you view the errors encountered in a trigger?
what is an execution plan? When would you use it? How would you view the execution plan? : Sql dba
What is the difference between sum and count in sql?