Link to home
Start Free TrialLog in
Avatar of YUSUF ATES
YUSUF ATES

asked on

sql, function

DELIMITER $
CREATE FUNCTION MAXSCOREID(START_STUDENT_ID INT, END_STUDENT_ID INT)
RETURNS INT
BEGIN
DECLARE STUDENT_ID INT;
BEGIN
      SELECT MAX(SCORE) INTO STUDENT_ID
      FROM STUDENT ST, SCORE S
      WHERE ST.STUDENT_ID = S.STUDENT_ID
      AND ST.STUDENT_ID BETWEEN 1 AND 10;
END;
RETURN student_id;
END$
DELIMITER ;

Hi. With the function above, I get the higher score but I want to get the student`s id who has the max score.  Any help, please?
ASKER CERTIFIED SOLUTION
Avatar of Chris Luttrell
Chris Luttrell
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of YUSUF ATES
YUSUF ATES

ASKER

Thanks a lot. I checked the links that you shared and they ar helpful.