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 |
What is the Extension of Oracle Database? As extension of Access Database is .mdb
Give syntax for SQL and ORACLE joins.
What is a cluster Key ?
find out the second highest salary?
55 Answers Cognizant, Nucsoft, Oracle, TCS, Wondersoft,
How do you find current date and time in oracle?
What is the usage of control file in oracle?
How to call a stored function in oracle?
Why do I get java.lang.abstractmethoderror when trying to load a blob in the db?
1. what is a single procedure? 2. suppose a view constructed on a query... after that in the master table a column was dropped, then what will be the status of that view? will it be invalid or something else? 3. what is mutating table error? how can you solve that problem? 4. suppose "select * from emp where empno=7788;" is running slow because of what ever the cause it is.. how can you fix it and make the execution faster? 5. will the snapshot of data will be stored in the RAM , where will ir be stored exactly. 6. how to delete 100 tables or 100000 tables' data from the schema without writing delete statement for no.of times. write an sql statement to do that job. 7. suppose a package contains so many cursors, procedures and all.. and we are using such types of procedures so many in a program. so the execution is to be stored all those packages and all to the RAM. utimately it is using many resources for each time execution. how can you reduce the time and using of resources for each execution because the query need to be run many times. how can you tune that? 8. suppose a procudere is there with specs as (a,b,c,d), all of these are IN mode only then while calling them should we pass all the 4 arguments? how to pass (b,c) only.. how ever the specs are wrote in the same order displayed in the above? 9. a function is returning a table type, how to access that function in a select statement? 10. i have a table in database A and another table in database B, how can you access the data of these two tables? write a query for that with dblinks. 11. i have two tables might have 15/20 columns in that.. i wanna send these columns(table) to the front end application for example you are using asp.net by writing a procedure. write that to perform the above job. 12. shall we create a table in the package? 13. shall we create a table in the procedure? 14. suppose i have 10 records, in that i want to select 7th record. write a query for that. cant you use rownum for this? 15. suppose my procedure has got around 20 select statements, in that some three select statements are running very slow. what will you write to detect which queries are running slowly? 16. what fields you use frequently in plan_table? 17. what is pipeline function? explain me with an example. 18. does a unique column can contain more than one null? 19. how many hints are there provided by oracle?
master table and child table performances and comparisons in Oracle ?
what is primary key?
which statement is running fastly ie insert or delete?