select top 10 * from yourtable order by NewID()

解决方案 »

  1.   

    接着问:如何将一个表中的5条记录,union到别一个表的任意的5条记录?
    即10条记录中有5条是固有的,另外5条则是随机的,但现在需要用union放在一起,怎么做?这样:select top 5 id,username,newid() from table1
    union 
    select top 5 id,username,newid() from table1 order by Newid
    是不行的,不能取出随机的数
      

  2.   

    select top 5 id,username,newid() as newid from table1
    union 
    select * from (
    select top 5 id,username,newid() as newid from table1 order by newid()) a order by Newid
      

  3.   

    select top 10 * from 
    (select *  from yourtable1
    union all
    select * from yourtable2 t1 ) t2
    order by newid()
      

  4.   

    谢谢,
    特别是j9988,
    现在我把分都给出了,---我要向 j9988(j9988) 学习~~~~