我的表结构为:ID L1 L2 L3 L4 L5 L6 M
代码的意思是:
查找出每行L1 L2 L3 L4 L5 L6的最大值,如果L1最大,则给M赋值1
如果L2最大,则给M赋值2
以此类推。
我的代码为:
CREATE procedure sel as
declare @index integer
declare @a float
declare @b float
declare @c float
declare @d float
declare @e float
declare @f float
set @index = 1
while(@index < 1297797)
begin
set @a =(select L1 from vv where ID = @index)
set @b =(select L2 from vv where ID = @index)
set @c =(select L3 from vv where ID = @index)
set @d =(select L4 from vv where ID = @index)
set @e =(select L5 from vv where ID = @index)
set @f =(select L6 from vv where ID = @index)
if(@a > = @b AND @a > = @c AND @a > = @d AND @a > [email protected] AND @a > = @f)
begin
update vv
set M = 1 where ID = @index
end
else if(@b > = @a AND @b > = @c AND @b > = @d AND @b > [email protected] AND @b > = @f)
begin
update vv
set M = 2 where ID = @index
end
else if(@c > [email protected] AND @c > = @b AND @c > = @d AND @c > [email protected] AND @c > = @f)
begin
update vv
set M = 3 where ID = @index
end
else if(@d > = @a AND @d > = @b AND @d > = @c AND @d > [email protected] AND @d > = @f)
begin
update vv
set M = 4 where ID = @index
end
else if(@e > = @a AND @e > [email protected] AND @e > = @c AND @e > [email protected] AND @e > = @f)