in Education by
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)

1 Answer

0 votes
by
All you are doing is selecting the maximum salary for the finance department for every employee. Do you perhaps need to pass the employee's department? E.g., select e.employeeid, e.employeename, salaryData(d.deptname,'max') as max_sal from employee e join department d on e.deptno=d.deptno; Which would at least provide the maximum salary of the department each employee belongs to and not just finance.

Related questions

0 votes
    I tried to create following function: CREATE OR REPLACE function CATEGORYTEST(n in number) return VARCHAR(200 ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    I tried to create following function: CREATE OR REPLACE function CATEGORYTEST(n in number) return VARCHAR(200 ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 17, 2022 in Education by JackTerrance
0 votes
    I tried to create following function: CREATE OR REPLACE function CATEGORYTEST(n in number) return VARCHAR(200 ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 16, 2022 in Education by JackTerrance
0 votes
    I am trying to make a a query against a table and am kind of stuck in constructing the WHERE ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 1, 2022 in Education by JackTerrance
0 votes
    I have a dilemma, I'm using Java and Oracle and trying to keep queries on PL/SQL side. Everything ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 22, 2022 in Education by JackTerrance
0 votes
    I have a dilemma, I'm using Java and Oracle and trying to keep queries on PL/SQL side. Everything ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 21, 2022 in Education by JackTerrance
0 votes
    If no header is specified, the block is said to be an _______________ PL/SQL block. (a) Strong (b ... Answers, Database Interview Questions and Answers for Freshers and Experience...
asked Oct 11, 2021 in Education by JackTerrance
0 votes
    We use ______________ name PL/SQL program objects and units. (a) Lexical Units (b) Literals (c) ... Answers, Database Interview Questions and Answers for Freshers and Experience...
asked Oct 11, 2021 in Education by JackTerrance
0 votes
    A line of PL/SQL text contains groups of characters known as (a) Lexical Units (b) Literals (c ... Query Optimization in portion Query Processing Techniques of Database Management...
asked Oct 10, 2021 in Education by JackTerrance
0 votes
    _______________ has made PL/SQL code run faster without requiring any additional work on the part of the ... topic in chapter Query Processing Techniques of Database Management...
asked Oct 10, 2021 in Education by JackTerrance
0 votes
    How many types of cursors are available in PL/SQL?...
asked Dec 17, 2020 in Technology by JackTerrance
0 votes
    What are the cursor attributes used in PL/SQL?...
asked Dec 17, 2020 in Technology by JackTerrance
0 votes
    The maximum number of slides per row in slide sorter view can be Select the correct answer from above options...
asked Dec 15, 2021 in Education by JackTerrance
0 votes
    In SQL Server Profile, I have it tracing SP:StmtStarting events. The "TextData" includes information like ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 12, 2022 in Education by JackTerrance
0 votes
    If I have a view in SQL which contains various computed columns, some of which could be very expensive, ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 19, 2022 in Education by JackTerrance
...