sql 成績函數設定
delimiter $$ //將結束符號改為$$
create function grade(score int)
returns char
begin
declare gd char(1);
if score =300 then
set gd="A";
elseif score Between 280 and 299 then
set gd="B";
elseif score Between 250 and 279 then
set gd="C";
elseif score Between 200 and 249 then
set gd="D";
else
set gd="E";
end if;
return gd;
END
$$
delimiter ; //將結束符號改回來;
create function grade(score int)
returns char
begin
declare gd char(1);
if score =300 then
set gd="A";
elseif score Between 280 and 299 then
set gd="B";
elseif score Between 250 and 279 then
set gd="C";
elseif score Between 200 and 249 then
set gd="D";
else
set gd="E";
end if;
return gd;
END
$$
delimiter ; //將結束符號改回來;
留言
張貼留言