how to get second highest salary in SQL(as/4000
Answers were Sorted based on User's Feedback
Answer / siva kumar yachamaneni
select max(salary) from Employee where salary<(SELECT
max(salary) from Employee)
| Is This Answer Correct ? | 0 Yes | 1 No |
Answer / prabir
Select * From employee emp1 Where 2 = (Select
Count(Distinct(emp1.salary)) From employee emp2 Where
emp2.salary > emp1.salary)
| Is This Answer Correct ? | 3 Yes | 5 No |
Answer / shasi
select sal from emp a where &n=(select count(sal) from emp
b where a.sal>=b.sal)
First u enter 1 means 1st highest sal.then enter2 2nd
highest sal
| Is This Answer Correct ? | 1 Yes | 3 No |
Answer / ashish raut
for 2nd highest price..............
SELECT max(Price) as [MaxPrice] from OrderDetails
where Price<(SELECT max(Price)as MaxPrice from OrderDetails)
for 3rd highest Price........
SELECT max(Price) as [MaxPrice] from OrderDetails
where Price<(SELECT max(Price)as MaxPrice from OrderDetails
where price<(SELECT max(Price)as MaxPrice from OrderDetails))
| Is This Answer Correct ? | 0 Yes | 2 No |
Answer / praveen
select * from emp where max(sal)
where rownow=2
| Is This Answer Correct ? | 0 Yes | 2 No |
Answer / apurva
Select *
From (
Select *
From (select * from emp order by sal desc)
Where rownum < 3 order by sal) ---> n+1 for example for
secound you should use 3
Where rownum < 2
| Is This Answer Correct ? | 4 Yes | 7 No |
Answer / sachin bhalsinge
select * from (select salary from employees order by salary
desc)where rownum=2;
| Is This Answer Correct ? | 5 Yes | 11 No |
Answer / ramesh.p
Select salary
From ( Select salary from emp order by salary desc)
Where rownum =2;
| Is This Answer Correct ? | 10 Yes | 19 No |
Answer / siddhartha
select sal, ename from employee where ROWNUM = 2 order by
sal;
| Is This Answer Correct ? | 12 Yes | 36 No |
how to rename an existing column in a table? : Sql dba
What are the uses of merge?
Display the total debit counts, total credit counts, sum of total debits, sum of total credits from an employee's transaction table (a single table) containing the following columns. Transaction_number Transaction_amount Transaction_date Transaction_type --> tells if the amount is a credit or a debit. As the query alone is important, the table is left with specifying just the field's name. Pls help me with this query.
How run sql*plus commands that are stored in a local file?
what is self join and why is it required? : Sql dba
What are the different ddl commands in sql?
What is the difference between count 1 and count (*) in a sql query?
What is procedure in pl sql?
how to remove records from table? no name 1 a 2 b 1 a 2 b 3 c
How insert into statements in sql?
Does sap use sql?
Where is sql database stored?
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)