# 数据库高手进 问题神奇

0

select
case  cast(rand()*10 as int)%4
when 0 then 0
when 1 then 1
when 2 then 2
when 3 then 3
else 4 end

if(abs(checksum(newid()))%4='')
begin
print '123'
end

if(abs(checksum(rand()))%4='')
begin
print '123'
end

http://www.cnblogs.com/xl888/archive/2009/03/25/1421477.html

http://www.cnblogs.com/xl888/archive/2009/03/26/1422060.html

0

0

select
case  cast(rand()*10 as int)%4
when 0 then 0
when 1 then 1
when 2 then 2
when 3 then 3
else 4 end

if (cast(rand()*10 as int)%4 == 0)

//print 0

else if (cast(rand()*10 as int)%4 == 1)

//print 1

else if (cast(rand()*10 as int)%4 == 2)

//print 2

else if (cast(rand()*10 as int)%4 == 3)

//print 3

else

//print 4

DECLARE @d int

SET @d = cast(rand()*10 as int)%4

SELECT

case  @d

when 0 then 0

when 1 then 1

when 2 then 2

when 3 then 3

else 4 end

Saga | 园豆：205 (菜鸟二级) | 2009-03-26 11:33
0

cast(rand()*10 as int)%4 的意思是从rand()方法返回的随机数乘以10再转换为int类型再余4

select
case  cast(rand()*10 as int)%4
when 0 then 0
when 1 then 1
when 2 then 2
when 3 then 3
else 4 end

if cast(rand()*10 as int)%4 < 3 and cast(rand()*10 as int)%4 > 2
begin
print 'smiting'
end

declare @cat int
set @cat = cast(rand()*10 as int)%4
select
case (@cat)
when 0 then 0
when 1 then 1
when 2 then 2
when 3 then 3
else 4 end

Cien | 园豆：205 (菜鸟二级) | 2009-03-26 15:07

您需要登录以后才能回答，未注册用户请先注册