Last answered:

18 Mar 2024

Posted on:

17 Mar 2024


All output we worked so far has only one Output (Average salary or emp_no), what if i want 2 output

Hello Team

1) So far we have created the function only to get average salary(single output), what if i want different output with average salary and max_from date. How can i rewrite this code to get the result ?

2) can i input many arguments in a single statement while calling the stored procedures and function ?

For exmaple:- we are retrieving data for Aruna Journel, what if i need output for one more alias, do i have redo the call function or can i add the second input argument in the same call function ?


1 answers ( 0 marked as helpful)
Posted on:

18 Mar 2024


Hi Vijayanandh!
Thanks for reaching out.

1) To modify your stored procedure to output both the average salary and the maximum from_date from the salaries table, you can adjust the SELECT statement within your procedure to include both of these values. Here's how you can rewrite your procedure:


CREATE PROCEDURE avg_salary_and_max_from_date()
        AVG(salary) AS average_salary,
        MAX(from_date) AS max_from_date


Then, you can call your procedure like this:

CALL avg_salary_and_max_from_date();

This version of the procedure will return two columns in its result set: average_salary for the average of all salaries in the table, and max_from_date for the latest from_date among all entries in the salaries table.

2) Yes, you can pass multiple arguments to a stored procedure or function in a single call, separating them with commas. If you need output for another alias, just ensure your procedure/function is designed to accept and process multiple inputs.

Hope this helps.

Submit an answer