how to find the second highest salary from emp table?
Answers were Sorted based on User's Feedback
Answer / velmurugan p
Select min(sal) from table_name where sal in(Select top 2 sal from table_name)
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / karthik.k
select max(salary) as second_highest from emp where salary
< (select max(salary) from emp)
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / pramod sharma
select f_name max(salary)from emp,dep
where salary<(select max(salary)from emp)
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / satish kumar
Select Top1 salary
from(select Distinct Top2 salary from employee order by salary DESC) a order by salary
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / rajkumar
SELECT * FROM TABLE WHERE columnName =
(SELECT MAX(column_name) FROM TABLE WHERE
column_name<(SELECT max(column_name) FROM TABLE))
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / mangesh pardhi
SELECT salary
FROM employee e
WHERE 2=(SELECT COUNT(DISTINCT salary)
FROM employees
WHERE e.salary<=salary)
--replace the number with 2,3,4 u wil find the that position
salary
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / kishan singh chilwal
SELECT MAX(sal)
FROM emp
WHERE sal <> (SELECT MAX(sal) FROM emp);
<> = not equal to
the SELECT statement in the WHERE clause will find the 1st max sal in the table
the 1st SELECT statement will find max sal in the table after excluding the first max sal
(ALTERNATE WAY)
SELECT MAX(sal)
FROM emp
WHERE sal not in (select max(sal) from emp );
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / syed hussain
select min(salary) from tbl_emp where salary in
(select top 4 salary from Tbl_emp order by salary desc)
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / hima
select sal from emp order by salary desc limit 1,1
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / subahar
SELECT MAX(average) AS Expr1
FROM sp
WHERE (average NOT IN
(SELECT MAX(average) AS Expr1
FROM sp AS sp_1))
| Is This Answer Correct ? | 0 Yes | 0 No |
In table three columns with 1 milion records(here there is no sequence values) i want add one more column with sequence values from the first how it is posible?
what is global variable in pl/sql
Explain two virtual tables available at the time of database trigger execution.
Why do we create views in sql?
how many ways we can we find the current date using mysql? : Sql dba
What is sql keyword?
What is sql scripting?
Enlist the characteristics of pl/sql?
what is the difference between blob and text? : Sql dba
select sal from emp group by sal
How to call DDL statements from pl/sql?
What is pl sql commands?
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)