如何避免每次的随机数大都一样的问题?

gdup 2003-12-04 10:53:26
我每次都会读进几万条数据,数据大多一样的,每次要抽取10%的数据出来,

但我要如何才能避免这个月抽到的数据中大多和上个月已抽到过呢?

请各位尽量说细详点,谢谢!
...全文
65 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
chao778899 2003-12-05
  • 打赏
  • 举报
回复
UP
流星尔 2003-12-05
  • 打赏
  • 举报
回复
select top 400 * into #a from tablename where 条件=本月 order by newid()
select top 100 * into #b from tablename where 条件=上月 order by newid()

select * from #a
union all
select * from #b

drop table #a
drop table #b

规定比率
流星尔 2003-12-05
  • 打赏
  • 举报
回复
select top 400 * into #a from tablename where 条件=本月
select top 100 * into #b from tablename where 条件=上月

select * from #a
union all
select * from #b

drop table #a
drop table #b

规定比率

zyhlhx 2003-12-04
  • 打赏
  • 举报
回复
写一个随机数发生器
pengdali 2003-12-04
  • 打赏
  • 举报
回复
SET ROWCOUNT 500
select * from (select top 500 * from 表 where 编号 not in (select 编号 from 上个月的数据) order by newid()) tem
union all
select * from 上个月的数据
pengdali 2003-12-04
  • 打赏
  • 举报
回复
你上个月的数据在那里存放?
gdup 2003-12-04
  • 打赏
  • 举报
回复
大力,谢谢你

我知道你说的这种方法,但我的意思是如果这样执行,那么在下个月又是同样的语句,差不多的数据下抽出来会不会有(不少)的重复呢?
pengdali 2003-12-04
  • 打赏
  • 举报
回复
--随机取500条
select top 500 * from 表 order by newid()

34,875

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧