【发布时间】:2018-12-02 15:05:59
【问题描述】:
这应该可以工作,但我得到了一个错误。我想从表中获取学分列并将其乘以 100。问题是获取给定学生 ID 和年份的学分数量并获得总付款。假设每笔积分为 100 美元。
delimiter //
create function fTest (stuYear varchar(4), stuID varchar(4))
returns varchar(200)
begin
declare msg varchar(200) default '';
if (stuYear = '' or stuYear is null) then
select 'Please input a valid year' into msg;
elseif (stuID = '' or stuID is null) then
select 'Please input a student id' into msg;
else
begin
if (msg = '' or msg is null) then
select ('No result found for student ID: ', stuID, ' at year: ', stuYear) into msg;
select (credits * 100) into msg from Students_Courses natural join Courses where sid=stuID and year=stuYear group by credits;
return msg ;
end if;
end ;
end if;
end ;
//
delimiter ;
【问题讨论】: