To find second largest salary in Employee table
Answers were Sorted based on User's Feedback
Answer / anil
select max(salary) from tbl_employee where salay <(select max(salary) from tbl_employee)
| Is This Answer Correct ? | 30 Yes | 6 No |
Answer / saravanakumar
SELECT MAX(SALARY) FROM EMPLOYEE WHERE SALARY NOT IN
(SELECT MAX(SALARY) FROM EMPLOYEE)
| Is This Answer Correct ? | 13 Yes | 1 No |
Answer / ram
select *from emp e where &n in(select count(distinct sal)
from emp m where e.sal<=m.sal);
which will ask's u like :
enter the value for n : 2 (enter 2)
gives u second highest.
| Is This Answer Correct ? | 4 Yes | 0 No |
Answer / amit
select max(salary) from employee where salary != (select max
(salary) from employee)
| Is This Answer Correct ? | 4 Yes | 1 No |
Answer / vikas kant
select Top 1 salary from emp_Table where salary in(select
Top 2 Salary from emp_Table order by salary desc)
| Is This Answer Correct ? | 6 Yes | 4 No |
Answer / zulfikar ali
SELECT MAX(SALARY)
FROM EMPLOYEE
WHERE SALARY NOT IN(SELECT TOP 1 SALARY FROM EMPLOYEE ORDER
BY SALARY DESC)
| Is This Answer Correct ? | 2 Yes | 1 No |
Answer / padmapriya
Thanks every one who replied for my question.
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / v rajkumar
Select min(salary)FROM emp WHERE salary IN (SELECT distinct
TOP 2 salary FROM emp ORDER BY salary desc)
OR
Select top 1 salary from (select distinct top 2 salary from
emp order by salary desc) emp order by salary
OR
select max(salary) from emp where salary <(select max
(salary) from emp)
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / satish
select salary from emp_Table_1 where 2= (select count(*)
form emp_Table_2 where emp_Table_2.salary < emp_Table_1.salary)
-satish
| Is This Answer Correct ? | 2 Yes | 2 No |
Answer / mohammad murtuza ali
select salary from employeetable where empsal is < max(salary)
| Is This Answer Correct ? | 4 Yes | 4 No |
How to delete duplicate records from a table?(for suppose in a table we have 1000 Records in that we have 200 duplicate Records , so ,how to findout that duplicate Records , how to delete those Records and arranged into sequence order? one more thing that there is no primary key at all)
What types of Joins are possible with Sql Server?
What is the purpose of sql profiler in sql server? : sql server database administration
What is the default value of an integer data type in sql server 2005?
What is the default Port No on which SQL Server listens?
How can you control the amount of free space in your index pages?
How to get a list of columns using the "sys.columns" view in ms sql server?
What is the difference between a Application Server and a Database
What is abstracting periodical?
How to provide values to user defined function parameters?
Which joins are sql server default?
How to connect of datebase with sql express.?
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)