Last answered:

19 Feb 2024

Posted on:

06 Jan 2024

0

error for question 9 in practice exam 3-SQL and solve

we must added READS SQL DATA in query: 

DROP FUNCTION IF EXISTS f_highest_salary;

DELIMITER $$

CREATE FUNCTION f_highest_salary (P_emp_no INTEGER)

RETURNS DECIMAL(10,2)

READS SQL DATA

BEGIN 

DECLARE v_highest_salary DECIMAL(10,2);

SELECT MAX(s.salary) 

INTO v_highest_salary FROM employees e

JOIN salaries s ON e.emp_no = s.emp_no

WHERE e.emp_no = P_emp_no;  -- Use the correct parameter name

RETURN v_highest_salary;

END$$


DELIMITER ;

2 answers ( 0 marked as helpful)
Instructor
Posted on:

19 Jan 2024

0

Hi Truong!
Thanks for reaching out.


Thanks for sharing this piece of information with the Community!


Best,
Tsvetelin

Instructor
Posted on:

19 Feb 2024

0

Hi Truong and Tsvetelin!

I hope you don't mind if I join the conversation.

@Truong: We assume you are taking the course without skipping any lectures and exercises. The *.txt downloadable from the Resources of this lecture: https://learn.365datascience.com/courses/sql/join-and-where-used-together/ 

Contains an explanation which, hopefully, should be solving the issue you are referring to.

Hope this helps.
Kind regards,
Martin

Submit an answer