select top 5 * from (select distinct * from Tablename) a order by newid()

解决方案 »

  1.   

    agree with j9988 :)
      

  2.   

    select distinct top 5 * from table
      

  3.   

    j9988的不错,select distinct top 5 * from table只能取前5条记录。
      

  4.   

    偷偷地说我不同意,可以吗?简单点:
    select distinct top 5 * from Tablename order by newid()
      

  5.   

    to:
    PFPF
    不过不可以
    试了么?好像不行耶
    出错
    ORDER BY items must appear in the select list if SELECT DISTINCT is specified.要不用这个 :)多了一列
    select distinct top 3 *,newid() from dis order by newid()