how will I find the first 5 highest salaried employees in
each dept in oracle.
Answers were Sorted based on User's Feedback
Answer / sunil panghal
select rownum as row_id,salary from (select salary from
employees order by salary) where rownum <6;
Is This Answer Correct ? | 1 Yes | 2 No |
Answer / rammohan
select rownum as row_id,sal from (select sal from
emp order by sal desc) where rownum <6;
Is This Answer Correct ? | 1 Yes | 2 No |
Answer / uttam
select sal from (SELECT distinct sal FROM emp order by sal
desc)
where rownum <6
Is This Answer Correct ? | 13 Yes | 15 No |
Answer / manjusure@yahoo.co.in
select * from emp e where 5> (select count(max(sal)) from emp
where e.deptno=deptno and sal>e.sal group by sal);
Is This Answer Correct ? | 4 Yes | 6 No |
Answer / mihir nasikkar
select *
from employee X
where salary in (select top 5 salary
from employee
where dept = X.dept
order by salary desc)
order by dept, salary desc
Is This Answer Correct ? | 2 Yes | 4 No |
Answer / mangesh
SELECT * FROM (SELECT * FROM EMP ORDER BY SALARY desc) WHERE ROWNUM < 6;
Is This Answer Correct ? | 0 Yes | 2 No |
Answer / md valiyullah
select max(sal)-5 from emp where dept = 'sale'
union all
select max(sal)-5 from emp where dept = 'purchase'
Is This Answer Correct ? | 0 Yes | 4 No |
Answer / dhanalakshmi
select salary
from employee
where rownum<6
group by deptno,salary
order by salary desc
Is This Answer Correct ? | 0 Yes | 9 No |
how to find find & delete duplicate rows from two different tables?
Explain the use of parfile option in exp command.
Is there a function to split a string in plsql?
Can u please explain me the Discussion on Except ,using cast like type cast. Question in the context of difference between two tables
What is a oracle database?
How to get a create statement for an existing table?
16. Display the order number, order line number and the shipping date. If the shipping date is null, display the string <not shipped yet>.
SQL> CREATE TABLE to_table 2 (col1 NUMBER); Table created. SQL> CREATE OR REPLACE TRIGGER statement_trigger 2 AFTER INSERT ON to_table 3 BEGIN 4 DBMS_OUTPUT.PUT_LINE('After Insert Statement Level'); 5 END; 6 / Trigger created. SQL> CREATE OR REPLACE TRIGGER row_trigger 2 AFTER INSERT ON to_table 3 FOR EACH ROW 4 BEGIN 5 DBMS_OUTPUT.PUT_LINE('After Insert Row Level'); 6 END; 7 / Trigger created. SQL> INSERT INTO TO_TABLE VALUES(1); After Insert Row Level After Insert Statement Level 1 row created. SQL> BEGIN 2 INSERT INTO TO_TABLE VALUES(2); 3 INSERT INTO TO_TABLE VALUES(3); 4 INSERT INTO TO_TABLE VALUES(4); 5 INSERT INTO TO_TABLE VALUES(5); 6 INSERT INTO TO_TABLE VALUES(6); 7 INSERT INTO TO_TABLE VALUES(7); 8 INSERT INTO TO_TABLE VALUES(8); 9 INSERT INTO TO_TABLE VALUES(9); 10 INSERT INTO TO_TABLE VALUES(0); 11 END; 12 / WAT LL BE THE O/P??? XPLAIN IT>>>>
How you open and close a cursor variable.Why it is required?
1.What is inline function in oracle and its purpose? 2.What is the equivalent operator for "different from pattern" in oracle? 3. If you define a variable in oracle, how it will be available? [a. Until database shut down b. Until table deleted c. until session get expired]
How to export your own schema?
Briefly explain what is literal? Give an example where it can be used?