Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

Why is the cursor important?

1083


How can I tell if sql is running?

1135


How does cross join work?

1010


what tools available for managing mysql server? : Sql dba

1134


What are the 3 types of behavioral triggers?

1319


What are the differences between implicit and explicit cursors?

1114


What is difference between nchar and nvarchar?

1104


Describe types of sql statements?

1108


what is a table in a database ? : Sql dba

1090


What is sql and how does it work?

1252


what are date and time data types? : Sql dba

1031


Why cannot I use bind variables in ddl/scl statements in dynamic sql?

1265


Explain architecture of sql server notification services?

1117


How to get list of all tables from a database?

1213


What is a temporal data type?

1114