将 sql server中的function函数转化为mysql的格式 请各位大佬指点一下

ALTER function [dbo].[GetStageByDay](@BabyBirthday date,@nowDate date)
returns nvarchar(5)
as
begin
declare @Stage nvarchar(5),@daySum int
set @daySum=datediff(day,@BabyBirthday,@nowDate)
set @Stage=(case when @daySum<0 and @daySum>=-90 then 'T3' 
    when @daySum<-90 and @daySum>=-180 then 'T2' 
    when @daySum<-180 and @daySum>=-277 then 'T1' 
    when @daySum>=0 and @daySum<=182 then 'S1' 
    when @daySum>182 and @daySum<=365 then 'S2' 
    when @daySum>365 and @daySum<=1095 then 'S3' 
    when @daySum>1095 and @daySum<=2190 then 'S4' 
    else 'other' end)
return @Stage
end

查看全部
namesonan
namesonan
2020/11/23 15:38
  • mysql
  • sql
  • 点赞
  • 收藏
  • 回答
    私信

1个回复