i have a table
eno dno sal
1 10 200
2 10 150
3 10 100
4 20 75
5 20 100
i want to get sal which is less than the avg sal of thri dept.
eno dno sal
2 10 150
3 10 100
4 20 75
Answer Posted / biswa
select *
from (select eno,dno,sal,avg(sal) over(partition by dno) as
avg_sal
from emp)
where sal<avg_sal;
OR
select e1.empno,e1.deptno,e1.sal
from emp e1
where sal>(select avg(sal) from emp e2
where e1.deptno=e2.deptno)
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What is the sql*loader? : aql loader
Explain what is sql?
What are the differences between implicit and explicit cursors?
What is #table in sql?
What is difference between table and view?
How would you convert date into julian date format?
What are the types of views in sql?
how to convert numeric values to character strings? : Sql dba
How can we optimize a sql query?
what are the t string functions available in tsql? : Transact sql
Is inner join faster than left join?
What is a call statement? Explain with an example.
what are dynamic queries in t-sql? : Transact sql
What is set serveroutput on?
What version is sql?