关于一个 SQL 随机 函数的问题
with t1 as(select Row_number() over(order by id) as B,fid from Order_Main where ov_bid like'%是%' and OV_CaoDan<>'废单' and OV_CaoDan<>'签单'and fstype<>3 and ftradetype in (2))select fid from t1 where B in( cast(ceiling(rand() * (select count(*) from t1) )as int) )
select top fid from t1 order by newid()
[解决办法]
直接用newid()嘛,还编号干啥
select top1 fid from Order_Main where ov_bid like'%是%' and OV_CaoDan<>'废单' and OV_CaoDan<>'签单'and fstype<>3 and ftradetype in (2))order by newid()
[解决办法]