title: PL/SQL function to view maximum salary
body: <p>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</p>
  
  <pre><code>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;
  / 
  </code></pre>
  
  <p>when i use function call</p>
  
  <pre><code>select salaryData('FINANCE','max') as max_sal from employee;
  </code></pre>
  
  <p>i got the ouput like:</p>
  
  <pre><code>max_sal|
  -------|
  20000  |
  20000  |
  20000  |
  20000  |
  20000  |
  -------
  </code></pre>
  
  <p>how can i show that this is the maximum salary of employeeid, employeename working in departmentname</p>