I have function that receives department name and an aggregation operation (average, maximum, minimum) and applies the operation on the salary of employees working on the given department and return the result
create or replace
function salaryData (p_depname varchar2, p_aggr_op varchar2)
return number
is
v_aggrr_op varchar2(20);
v_sal_max number;
v_sal_min number;
v_sal_avg number;
begin
select max(e.salary), min(e.salary), avg(e.salary)
into v_sal_max, v_sal_min, v_sal_avg
from employee e join department d
on e.deptno=d.deptno
where d.deptname=p_depname;
if p_aggr_op in ('max','MAX') then
return v_sal_max;
end if;
if p_aggr_op in ('min','MIN') then
return v_sal_min;
end if;
if p_aggr_op in ('avg','AVG') then
return v_sal_avg;
end if;
end salaryData;
/
when i use function call
select salaryData('FINANCE','max') as max_sal from employee;
i got the ouput like:
max_sal|
-------|
20000 |
20000 |
20000 |
20000 |
20000 |
-------
how can i show that this is the maximum salary of employeeid, employeename working in departmentname
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)