SQL 使用WHILE语句求1~10之间的累加各,并输出结果,怎么编写,请详细写出来。
发布网友
发布时间:2022-05-07 11:51
我来回答
共2个回答
热心网友
时间:2023-10-30 06:04
DECLARE @I INT
,@s int
SET @I = 1
SET @S = 0
WHILE @I <=10
BEGIN
SET @S = @S + @I
PRINT @S --这是累加的和
PRINT @I
SET @I= @I+1
CONTINUE
END
热心网友
时间:2023-10-30 06:04
declare @num int
declare @sum int
set @sum=0
set @num=1
while (@num<=10)
begin
set @sum=@sum+@num
set @num=@num+1
end
print @sum
热心网友
时间:2023-10-30 06:04
DECLARE @I INT
,@s int
SET @I = 1
SET @S = 0
WHILE @I <=10
BEGIN
SET @S = @S + @I
PRINT @S --这是累加的和
PRINT @I
SET @I= @I+1
CONTINUE
END
热心网友
时间:2023-10-30 06:04
declare @num int
declare @sum int
set @sum=0
set @num=1
while (@num<=10)
begin
set @sum=@sum+@num
set @num=@num+1
end
print @sum
热心网友
时间:2023-10-30 06:04
DECLARE @I INT
,@s int
SET @I = 1
SET @S = 0
WHILE @I <=10
BEGIN
SET @S = @S + @I
PRINT @S --这是累加的和
PRINT @I
SET @I= @I+1
CONTINUE
END
热心网友
时间:2023-10-30 06:04
declare @num int
declare @sum int
set @sum=0
set @num=1
while (@num<=10)
begin
set @sum=@sum+@num
set @num=@num+1
end
print @sum
热心网友
时间:2023-10-30 06:04
DECLARE @I INT
,@s int
SET @I = 1
SET @S = 0
WHILE @I <=10
BEGIN
SET @S = @S + @I
PRINT @S --这是累加的和
PRINT @I
SET @I= @I+1
CONTINUE
END
热心网友
时间:2023-10-30 06:04
declare @num int
declare @sum int
set @sum=0
set @num=1
while (@num<=10)
begin
set @sum=@sum+@num
set @num=@num+1
end
print @sum
热心网友
时间:2023-10-30 06:04
DECLARE @I INT
,@s int
SET @I = 1
SET @S = 0
WHILE @I <=10
BEGIN
SET @S = @S + @I
PRINT @S --这是累加的和
PRINT @I
SET @I= @I+1
CONTINUE
END
热心网友
时间:2023-10-30 06:04
declare @num int
declare @sum int
set @sum=0
set @num=1
while (@num<=10)
begin
set @sum=@sum+@num
set @num=@num+1
end
print @sum
热心网友
时间:2023-10-30 06:04
DECLARE @I INT
,@s int
SET @I = 1
SET @S = 0
WHILE @I <=10
BEGIN
SET @S = @S + @I
PRINT @S --这是累加的和
PRINT @I
SET @I= @I+1
CONTINUE
END
热心网友
时间:2023-10-30 06:04
declare @num int
declare @sum int
set @sum=0
set @num=1
while (@num<=10)
begin
set @sum=@sum+@num
set @num=@num+1
end
print @sum
热心网友
时间:2023-10-30 06:04
DECLARE @I INT
,@s int
SET @I = 1
SET @S = 0
WHILE @I <=10
BEGIN
SET @S = @S + @I
PRINT @S --这是累加的和
PRINT @I
SET @I= @I+1
CONTINUE
END
热心网友
时间:2023-10-30 06:04
declare @num int
declare @sum int
set @sum=0
set @num=1
while (@num<=10)
begin
set @sum=@sum+@num
set @num=@num+1
end
print @sum