I have one table :EID,Depid,ename,sal
I want to have max(sal) in each department.
Answers were Sorted based on User's Feedback
Answer / omar
select e.department_id,max(e.salary)
from employees e
group by e.department_id
order by e.department_id desc;
| Is This Answer Correct ? | 2 Yes | 0 No |
Answer / vengalrao
Dear Friends,
Depends upon table u can pick one max value is possible,one
table u cannot pick max value of all columans , then u can
refer one any ne column
select depid,max(sal) from <table name> group by depid;
| Is This Answer Correct ? | 2 Yes | 1 No |
Answer / narasimha
select e.eid,e.sal,e.depid,e.ename,e.sal from emp e
where 1>(select count(*) from emp w where e.sal<w.sal and
e.depid=w.depid) order by e.deptno asc
| Is This Answer Correct ? | 0 Yes | 3 No |
Answer / venkat
select * from emp_test where sal IN(select max(sal) from
emp_test group by deptno)
| Is This Answer Correct ? | 1 Yes | 6 No |
What is the use of Control File ?
What is the difference between I and G in Oracle?
You have one employee table having 3 entries emp_id, Mgr_id and salary. Mgr_id is also referencing emp_id. so now find out the emp_id which are having the second highest salary, under a particular manager.
how do u know the total no of rows in a table?
How to create additional tablespaces for an new database?
Whether Oracle satisfy more codd rules or db2 satisfy more codd rules? How meny of each can satisfy ? Please answer me. Advance thanks
How to update rows in table, suppose i have lacks of rows in table how to update total table with update statement. Can u please any one answer this question with update statement.
can u call user defined functions in select statements
What are various constraints used in SQL?
What is a proxy object?
What is a directory object?
How to recover a dropped index?