日期:2014-05-18 浏览次数:20580 次
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()
------解决方案--------------------