MMSCAU 发表于 2013-1-26 13:35:52

oracle 从每种类型里面抽取随机抽取一个

select *
  from (select *
          from tableA
         where type = 'A'
         order by dbms_random.value)
 where rownum = 1
 
union all
select *
  from (select *
          from tableA
         where type = 'B'
         order by dbms_random.value)
 where rownum = 1
union all
select *
  from (select *
          from tableA
         where type = 'C'
         order by dbms_random.value)
 where rownum = 1
 
union all
select *
  from (select *
          from tableA
         where type = 'D'
         order by dbms_random.value)
 where rownum = 1
 
 union all
select *
  from (select *
          from tableA
         where type = 'E'
         order by dbms_random.value)
 where rownum = 1
页: [1]
查看完整版本: oracle 从每种类型里面抽取随机抽取一个