find out first highest salary?
Answers were Sorted based on User's Feedback
Answer / surya
select * from emp where &n-1=(select count(distinct sal)
from emp e where emp.sal<e.sal);
For example:-
If you enter n=1,it will display first highest salary
if you enter n=2,it will display second highest salary
......
if you enter n=nth,it will display nth salary
| Is This Answer Correct ? | 9 Yes | 0 No |
SELECT DISTINCT salary FROM (SELECT DISTINCT salary,ROWNUM
rn FROM employee ORDER BY salary desc) WHERE rn=1;
| Is This Answer Correct ? | 6 Yes | 2 No |
Answer / ela tiku
select max(sal) from emp
<<<assuming emp is the table name and sal is the column
name>>>
| Is This Answer Correct ? | 4 Yes | 0 No |
Answer / tulasi
select * from emp x where 1=(select count(distinct sal)
from emp y where x.sal<=y.sal);
query to find nth sal
select * from emp x where &n=(select count(distinct sal)
from emp y where x.sal<=y.sal);
| Is This Answer Correct ? | 5 Yes | 2 No |
Answer / vali
according to samir kumar sahoo we cant find ans i think
bcoz
if u enter rownum='x' u can not find the data
select * from emp where rownum=10
ans; no rows found
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / suren
hi Im SureRishi
SELECT *
FROM Employee E1
WHERE (4-1) = (
SELECT COUNT(DISTINCT(E2.Salary))
FROM Employee E2
WHERE E2.Salary > E1.Salary)
| Is This Answer Correct ? | 1 Yes | 0 No |
What is an Oracle view?
What is the difference between sharding and replication?
How to execute the package in oracle?
What is a Sequence ?
Why we choose emp number as primarykey?
What is the difference between a primary key & a unique key?
1) WIll all the user get the DEFAULT profile, if their current profile got deleted at any point of time? 2) What are the Situation we need to MOVE the TABLE between T.spaces? 3) What is the use of MOVING the TABLE between SCHEMA'S? 4) What are the Table Clause, Segment Clause and the Datafile Clause which will override each other? 5) Explain SORT_AREA_SIZE of Tempfile to make UNIFORM SIZE
WHAT IS ecc 6.0
What is the max number of columns in an oracle table?
Explain oracle data types with examples?
How to use "startup" command to start default instance?
How can we manage the gap in a primary key column created by a sequence? Ex:a company has empno as primary key generated by a sequence and some employees leaves in between.What is the best way to manage this gap?