Home > database >  May 1 to 20
May 1 to 20

Time:10-28

Using T - SQL programming and 1 to 20 odd number of the product

CodePudding user response:

 
Declare @ int x

Select @ x=isnull (@ x, 1) * number
From the master. The dbo. Spt_values
Where type='P'
And the number between 1 and 20
The number and % 2!=0

Select @ x 'x'

/*
X
-- -- -- -- -- -- -- -- -- -- --
654729075

Line (1) affected
*/

CodePudding user response:



Declare @ sum int=1;

Declare @ n int=1;

While @ n & lt;=20

The begin

The set @ sum=@ @ sum * n

The set @ n=@ n + 2

End

Print 'result=' + cast (@ sum as varchar (100))

Go





Result=654729075

CodePudding user response:

How feel in a post,

https://bbs.csdn.net/topics/392729890

CodePudding user response:

Select the power (2, sum (log (number, 2)))
From the master. The dbo. Spt_values
Where type='P'
And the number between 1 and 20
The number and % 2!=0
/*
X
654729075
*/

CodePudding user response:

Declare @ I int
Declare @ sac int
The set @ I=1
The set @ sac=1
While @ i<=20
The begin
If @ I % 2=1
The set @ sac=@ sac * @ I
The set @ I=@ I + 1
End
Print @ sac
  • Related