find out the third highest salary?
Answers were Sorted based on User's Feedback
Answer / hanumantha r challa
select * from emp a where &n=(select count(b.sal) from emp
b where b.sal>=a.sal);
Is This Answer Correct ? | 0 Yes | 1 No |
Answer / raghav
select * from (
select Name,
Salary,
Dept,
Rank()over (order by salary desc) RANK
from Employee)
where RANK = 3
Is This Answer Correct ? | 0 Yes | 1 No |
Answer / joel
select sal from emp
where sal<(select max(sal) from emp
where sal in (select sal from emp
where sal < ( select max(sal) from emp)))
Is This Answer Correct ? | 6 Yes | 8 No |
Answer / sudesh indore
select ( salary) as sal from employee ORDER by
salary DESC limit 2,1
------------
i hope that will help u thanx
Is This Answer Correct ? | 0 Yes | 2 No |
Answer / esha gautam
SELECT SAL FROM EMP E WHERE &N-1 =(SELECT COUNT(*) FROM EMP
WHERE E.SAL<SAL);
HERE N FOR NTH SALARY!!!!!!!!!!!!!!!!!!!!
Is This Answer Correct ? | 0 Yes | 2 No |
Answer / amrish singh
this is the query for retrieving nth highest salary from
table emp
select e.sal
from emp e
where n-1=(select count(*) from emp s where s.sal>e.sal)
putting the value of n we get the required result.
Is This Answer Correct ? | 0 Yes | 2 No |
Answer / venkatranjith e
Hi All,
This query will give you the o/p.
Select * from EMP A where &n= (select count (distinct
(sal)) from EMP B where B.sal>A.sal)
n = 3 , to display 3rd largest salary.
Is This Answer Correct ? | 0 Yes | 2 No |
Answer / vishawjeet saini
SELECT MIN(sal) FROM emp WHERE
sal IN (select sal from emp order by sal desc limit 3)
Its works on almost databases including postgres.
Is This Answer Correct ? | 0 Yes | 2 No |
forget the book first
Empsal table data
700
500
100
900
400
200
600
750
query to find second highest salary from table Empsal
mysql>select distinct(max(e.salary)) from Empsal e
>where e.salary in(
>select e1.salary from Empsal e1 where e1.salary<(select max(salary) from Empsal));
Output=750
query to find third highest salary from table Empsal
mysql>select distinct(max(e.salary)) from Empsal e
>where e.salary in(
>select e1.salary from Empsal e1 where e1.salary<
>(select max(e1.salary) from Empsal e1
>where e1.salary IN(
>select e2.salary from Empsal e2 where
>e2.salary<(select max(salary) from Empsal))));
Output=700
don't args without run
amitsing2008@gmail.com(amy is back again)
Is This Answer Correct ? | 3 Yes | 5 No |
Answer / arungkd
Hey dudes ,
i have worked out this question and got the Answer.... here
it is given below...
SELECT min(income) AS salary FROM [user] WHERE income in
(SELECT DISTINCT top 3 income FROM [user] order by income
desc )
Is This Answer Correct ? | 3 Yes | 6 No |
The table has 3 columns 4 rows. The output is which column has least null values( A COL SHOULD BE THE OUTPUT) Write the query plz. A B C ================ 1 NULL 2 NULL 3 4 NULL 5 6 7 NULL NULL O/P C = 2 4 6
How to convert a string to a date in oracle database?
How to get last row id?
What is rich query?
How to do paging with oracle?
14. Display the item_cost and then round it to the nearest hundred, ten, unit, tenth and hundredth
What is a read only transaction in oracle?
ex. one table is having 1 column with 10 records , then how to display all the values in row wise ?
What is the relation of a user account and a schema?
What is translate in oracle?
how to store only time in a data base table
can we insert any row to dual table if i got the permission from DBA