取前十条记录,但是有一条必须包括在取出来的数据当中。

解决方案 »

  1.   

    select [字段名] from(
       select * from(
          select tab1.*,dbms_random.value rd from tab1)order by rd)
    where rownum<10 and not([你的条件])
    union
    select [字段名] from tab1 where [你的条件]
      

  2.   

    select * from (select * from staff order by dbms_random.random) 
        where rownum < 4 
    表示从STAFF表中随机取3条记录<转自 葛宏宾的专栏>
    http://www.cnblogs.com/binary/archive/2005/04/01/130552.html