随机概率测试

创建一个表统计
create table t_test(ip char(15))

--truncate table t_test;

declare @i int ;
set @i=0;

--循环1000次
while @i<1000
begin
--2015-1-20
declare @randnum int;
set @randnum=cast(ceiling(rand() * 10) as int)
--概率让47的IP出现的概率在30%以内
if(@randnum%3=0)
insert into t_test values('192.168.1.47');
else
insert into t_test values('192.168.1.40');

set @i=@i+1;

end

--统计记录出现的次数
select COUNT(1),ip from t_test group by ip

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-04
  • 2021-09-25
  • 2021-12-05
  • 2021-12-03
  • 2022-12-23
猜你喜欢
  • 2022-02-08
  • 2022-01-14
  • 2021-11-05
  • 2021-08-24
  • 2022-12-23
  • 2021-08-20
相关资源
相似解决方案