MySQL 高级 - 存储过程 - 语法 - case结构
-- 给定一个月份, 然后计算出所在的季度
create procedure pro_test7(mon int)
begin
declare result varchar(10);
case
when mon>=1 and mon <= 3 then
set result='第一季度';
when mon>=4 and mon <= 6 then
set result='第二季度';
when mon>=7 and mon <= 9 then
set result='第三季度';
ELSE
set result='第四季度';
end case;
select concat('传递的月份为:',mon,', 计算出的结果为:',result) as content;
end$