Print 3 highest salary
Answers were Sorted based on User's Feedback
Answer / manish nautiyal
select salary from table_name order by salary desc limit 3;
| Is This Answer Correct ? | 35 Yes | 4 No |
Answer / priya
select top 1 salary from ( select top 3 salary from ( select
distinct salary from employee order by desc ) order by asc);
| Is This Answer Correct ? | 7 Yes | 1 No |
Answer / john peter
select salary from tablename order by salary desc limit 3;
| Is This Answer Correct ? | 6 Yes | 1 No |
Answer / m gangadhar
select * from (select a.* from employees a order by
a.salary desc) where rownum <= 5
| Is This Answer Correct ? | 7 Yes | 5 No |
Answer / saraswathi muthuraman
SQL> desc emp_test;
Name
-----
EMP_NO SAL
DEP_NO
SQL> select * from emp_test;
1001 10000 11
1001 10000 11
1002 100 11
1003 20010 11
1004 99 11
1005 50 11
1006 25 11
SQL> select a.EMP_NO,a.SAL,a.DEP_NO from emp_test a, (select
SAL,rank() over(order by sal desc) as rank_val from emp_test
group by sal)b where
2 a.sal=b.sal and b.rank_val =3;
1002 100 11
1 row selected.
| Is This Answer Correct ? | 2 Yes | 0 No |
Answer / saraswathi muthuraman
The previous post is to find the 3rd highest value.
Please find the below qry to find the top 3 highest salary
SQL> select a.EMP_NO,a.SAL,a.DEP_NO from emp_test a, (select
SAL,rank() over(order by sal desc) as rank_val from emp_test
group by sal)b where
2 a.sal=b.sal and b.rank_val <=3;
1003 20010 11
1001 10000 11
1001 10000 11
1002 100 11
4 rows selected.
| Is This Answer Correct ? | 0 Yes | 1 No |
Answer / satya
SELECT salary FROM emp order by ordering DESC limit 2,1
| Is This Answer Correct ? | 0 Yes | 1 No |
Answer / lokesh das
Using a single query not sub-query
SELECT * FROM `employee` ORDER BY salary DESC LIMIT 2, 1
| Is This Answer Correct ? | 0 Yes | 2 No |
Answer / ankammarao.v
select min(EmpSal) as sal3 from EmpInfo
where EmpSal in(select distinct top 3 EmpSal from Empinfo
order by EmpSal desc)
| Is This Answer Correct ? | 7 Yes | 15 No |
What are numeric data types?
What is the difference between primary and unique key
How can you find out the version of the installed mysql?
What are features of mysql?
I want to insert userid of a customer,order time,etc in a table called ordermaster with orderid as primary key.Same time the product codes and required quantities (a1,2 and a2 4 and so on)inserted in another table orderdetails with same orderid reference.How the code will be in JSP using MySQL?
How to dump a table from a database.
How do I edit a stored procedure in mysql?
What is a csv table?
1.how to fetch a value and Execute store procudure in mysql(INNODB) using phpMyAdmin? 2.can i wright a package in mysql database(INNODB)?
What is mysql command line?
How do I install mysql on windows 7?
What is the default password for mysql?
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)