--drop function gret create function dbo.gret (@r0 money,@r1 money,@r2 money,@r3 money,@r4 money,@r5 money,@r6 money,@r7 money) returns money as begin declare @tmp money set @tmp = @r0 if(@tmp < @r1) set @tmp = @r1 if(@tmp < @r2) set @tmp = @r2 if(@tmp < @r3) set @tmp = @r3 if(@tmp < @r4) set @tmp = @r4 if(@tmp < @r5) set @tmp = @r5 if(@tmp < @r6) set @tmp = @r6 if(@tmp < @r7) set @tmp = @r7 return @tmp end
sql数据库自定义函数,比较一行中多个字段的最大值(类似orcal中的greatest)
最大最小都可以中这种方法比较