Find out the 3rd highest salary?
Answers were Sorted based on User's Feedback
Answer / a.jyothsna
select a.sal
from emp a
where 3=(select distinct(count(b.sal))
from emp b
where a.sal<=b.sal)
Is This Answer Correct ? | 100 Yes | 45 No |
Answer / kaushal kassi
select distinct a.sal
from employee a
where 3=(select count(distinct b.sal)
from employee b
where a.sal<=b.sal)
Is This Answer Correct ? | 24 Yes | 12 No |
Answer / srikanth
select q.sal
from emp q
where 3=(select distinct(count(b.sal))
from emp b
where q.sal<=b.sal)
Is This Answer Correct ? | 17 Yes | 10 No |
Answer / karna
Hi Friends,
to get the nth highest value of a column in a table,please
use the below simple query
select min(column) from table where column in(select top n
column from table)
any queries,mail me at karun84@gmail.com
Is This Answer Correct ? | 9 Yes | 2 No |
Answer / karna
Hi Friends,
sorry,last answer was wrong.
I have changed the query,check now
to get the nth highest value of a column in a table,please
use the below simple query
select min(column) from table where column in(select top n
column from table order by desc)
any queries,mail me at karun84@gmail.com
Is This Answer Correct ? | 10 Yes | 3 No |
Answer / surendra kumar dattatrey
Select * from Emp where Salary =
(Select max(Salary) from Emp where Salary <
(Select max(Salary) from Emp where Salary <
(Select max(Salary) from Emp where Salary <.....N))))
Is This Answer Correct ? | 8 Yes | 2 No |
Answer / abhay
select distinct(sal) from emp a where 3=(select
count(distinct(sal) from emp b where a.sal<=b.sal);
somebody tell me he logic....!
Is This Answer Correct ? | 6 Yes | 1 No |
Answer / sachin
select distinct(sal) from employee order by sal desc limit 2,1;
Is This Answer Correct ? | 5 Yes | 0 No |
Answer / anjali
select min(column_name) from table where column in(select
top n
column_name from table order by column_name desc)
Is This Answer Correct ? | 4 Yes | 1 No |
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
RUN THE QUERY THEN ARG
amitsing2008@gmail.com(amit is back)
Is This Answer Correct ? | 2 Yes | 0 No |
What is the difference between RDBMS and DBMS?
20 Answers Practical Viva Questions, Sapient, Stag Computers,
Write the alter statement to enable all the triggers on the t.students table.
Differentiate between % rowtype and type record.
Which is faster view or stored procedure?
Does a user_objects view have an entry for a trigger?
What is cursor explain with example?
What does select top 1 do in sql?
which will default fire first statement level trigger or row level trigger
2 Answers Cap Gemini, Data Vision,
How to convert ms-excel file to oracle table?
a. Can you delete data from a View. b. If Yes, can you delete it if there are multiple tables c. If No, can you delete if there is single source table which is joining.
What is assignment operator in pl sql?
what is Difference between Having and Where clause?