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 / mahalakshmi s

select * from (select id,(case when sal < avg(sal) over(partition by id)  then sal else 0 end) avg_val from dept) a where avg_val !=0;

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can a foreign key have a different name?

510


How do I remove duplicates in two columns?

506


Explain cursor types?

578


how can we submit a form without a submit button? : Sql dba

534


How many tables can a sql database have?

528






What are the different sql languages?

536


Give the order of sql select?

607


Advantages and disadvantages of stored procedure?

576


Can we call a function containing dml statements in a select query?

537


What is procedure in pl sql?

532


What is cascade in sql?

557


How do I create a memory optimized filegroup?

523


What is the purpose of the partition table?

540


What can you do with pl sql?

554


Is sql a oracle?

519