我想从Marks Column驱动获得的标记,总标记和平均列,这是varchar类型。
我写的存储过程花了很多时间执行。由于表包含346599条记录。存储过程有3个更新quires init。
Declare @Max_ROWss int
Declare @j int
Declare @Marks_Obtained int
Declare @Total_Marks int
Declare @Marks nvarchar(50)
Declare @Average int
Set @MAx_ROWss = (Select Count([Row Number]) From [dbo].[Drv Tevta 3 Full] ) -- Max([Row Number]) will also work
Set @j = 1
while (@j<= @MAx_ROWss)
Begin
set @Marks = (select [Marks] from [dbo].[Drv Tevta 3 Full] where [Row Number] = @j)
Set @Total_Marks =cast((select SUBSTRING(@Marks, CHARINDEX('/', @Marks) + 1, 10)) as int)
set @Marks_Obtained = CAST((Select SUBSTRING(@Marks,0,CHARINDEX('/',@Marks))) as int)
Update [dbo].[Drv Tevta 3 Full]
set [Marked Obtained] = @Marks_Obtained
where [Row Number] = @j
Update [dbo].[Drv Tevta 3 Full]
set [Total Marks] = @Total_Marks
where [Row Number] = @j
set @Average = ((@Marks_Obtained*100)/@Total_Marks)
Update [dbo].[Drv Tevta 3 Full]
set [Average] = @Average
where [Row Number] = @j
set @j = @j + 1
End
有没有更好的方法可以做到?或者我只需要等待!
答案 0 :(得分:2)
您不需要Map<String,Map<String,Object>> map =
list.stream()
.collect(Collectors.toMap(m -> m.keySet().iterator().next(),
Function.identity()));
循环来执行此操作
while