Write a function to accept department name and display the average salary of employees in that department.

Write a function to accept department name and display the

average salary of employees in that department.



Write a function to accept department name and display the

average salary of employees in that department.


--->>>


create or replace function emp(v varchar(25)) returns int  as

'

declare

r1 department%rowtype;


r2 employee%rowtype;




ch int := 0;


begin


for r1 in select * from department where dname = v

    loop

    if r1.dno= r2.no      then 

            

        loop    

             select avg(salary) from epmloyee,department where department.dno= employee.dno AND  dname= v;

                

                    raise notice '' % '', r2.salary;

                end if;

              ch := ch+1;

        end loop;

    end if ;


    end loop;


return ch;

end;

'language'plpgsql';



Post a Comment

0 Comments