sql 随机数
来源:百度知道 编辑:UC知道 时间:2024/06/10 05:55:43
30选7 从1到30中随机选出7个数
谢谢啊
谢谢啊
;with c
as
(select 1 as ID
union all
select ID+1 from c where ID<30)
select top 7 ID from c order by newID()
ID
-----------
2
6
9
3
30
11
8
(7 个资料列受到影响)
SQL 中好像没有这种随机抽取的方式,只有随机抽取多少条记录。
select top N * from 表 order by newid()