how to find the second highest salary from emp table?

Answer Posted / hridayeshwar rao

select max(age) from yd where age<(select max(age) from HK) ; /// True two table Highest

SELECT * FROM HK E1 WHERE 1 =(SELECT COUNT(DISTINCT age) FROM HK E2 WHERE E1.age < E2.age); ///Second Hightest age RT single table

select age from hk e1 where (3-1) = (select count(distinct (e2.age)) from yd e2 where e2.age>e1.age);//// same True Second Hight age RT two table

select max(age) from YD where age not in (select max(age) from YD); //second hight age in single table

Suppose that salery=age

Thanks !!!

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Do prepared statements prevent sql injection?

532


what is a join? : Sql dba

565


what are the maximum number of rows that can be constructed by inserting rows directly in value list? : Transact sql

507


Why is pl sql needed?

517


Why commit is not used in triggers?

587






Mention what does plvtab enables you to do when you showthe contents of pl/sql tables?

673


what is the difference between truncate and delete statement? : Transact sql

552


What does plv msg allows you to do?

683


What are all the different normalizations?

591


How to rename a table?

558


How many types of triggers are there in pl sql?

575


How do I count duplicates in sql?

552


what is the difference between mysql_fetch_object and mysql_fetch_array? : Sql dba

556


How to add new employee details in an employee_details table with the following details

653


How to change a value of the field ‘salary’ as 7500 for an employee_name ‘john’ in a table employee_details?

910