dcsimg
i want the sql statement which will give the second highest salary from employee table
4 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Friday, May 20, 2005 03:24 AM

i want the sql statement which will give the second highest salary from employee table

Re: i want the sql statement which will give the second highest salary from employee table

Posted By:   Chiranjeeva_Reddy  
Posted On:   Friday, July 1, 2005 11:41 AM

select max(salary) from employee where salary not in(select max(salary) from employee)

Re: i want the sql statement which will give the second highest salary from employee table

Posted By:   Anonymous  
Posted On:   Thursday, June 2, 2005 08:20 AM

SELECT *
FROM (select s1.*, rownum num from
(select * from salary order by amount DESC) s1
where rownum <= 2 )
WHERE num >= 2;

Re: i want the sql statement which will give the second highest salary from employee table

Posted By:   adarsh_p  
Posted On:   Tuesday, May 31, 2005 10:10 AM

I can tell u the logic.First sort content of the table according to the salary in ascending order.So first record will be always the max salary,so that second will be the second highest salary.

Re: i want the sql statement which will give the second highest salary from employee table

Posted By:   Anonymous  
Posted On:   Friday, May 20, 2005 04:24 AM

Just query the employee table, ordering by salary from high to low. Then pick the second row in the ResultSet. I think that's easier and faster than constructing a complex SQL query.
About | Sitemap | Contact