The solution has two select statement
Please i need an explain to the solution. I don't understand why the solution has two select statement. In the first statement, we had two variables declared. So i was looking at how two statements can be returned. Then i saw another select statement. That really confused me. Please explain , also can this question be solved with just one select statement.
The video explanation was clear and easy to understand but the assignment is hard
Thanks for reaching out!
Could you please explain which code you are referring to and paste a screenshot? This can help us assist you better. Thank you.
Looking forward to your answer.
Thanks for reaching out.
1. The first one we create to feed data into
v_max_from_date, then we use this value in the second SELECT statement.
We can solve it with one SELECT statement also. The code is:
CREATE FUNCTION f_emp_info_v2(p_first_name varchar(255), p_last_name varchar(255)) RETURNS decimal(10,2)
DETERMINISTIC NO SQL READS SQL DATA
DECLARE v_salary decimal(10,2);
FROM employees e
salaries s ON
e.emp_no = s.emp_no
e.first_name = p_first_name
AND e.last_name = p_last_name
ORDER BY s.from_date DESC
SELECT f_emp_info_v2('Aruna', 'Journel');
Hope this helps.