要求  假如有一个表叫table  里面有2个字段   类型(保存数据有:类型1,类型2,类型3)  题型(保存数据有:选择题,判断题,填空题)    要求从该表中 查询70个选择题,30个判断题  并且题目类型为类型1和类型3
延伸:
  如何满足上述条件的同时随机的获取这100个题目谢谢了  急啊再次谢谢我会一直等的  今天不行 明天也等

解决方案 »

  1.   

    select * from table where 题型=选择题 and (类型=1 or 类型=3) and rownum<=70
    union all
    select * from table where 题型=判断题 and (类型=1 or 类型=3) and rownum<=30
      

  2.   

    UPC05070000
    你的语句成功满足了 条件 那么如何从数据表中随机获取这100个题目呢 谢谢
      

  3.   

    哈哈 我成功实现了随机了  
    谢谢UPC05070000
    谢谢你的union all  
    我的解决方法select * from (select * from QUESTIONTABLE order by dbms_random.value) where QCLASS='选择题' and (QTYPE='安全' or QTYPE='技术') and rownum<=3
    union all
    select * from (select * from QUESTIONTABLE order by dbms_random.value) where QCLASS='判断题' and (QTYPE='安全' or QTYPE='技术') and rownum<=1
      

  4.   


    select type1,type2
       from(
            select type1,type2
              from tbname
             where type2 = '选择题'
               and type1 in('类型1','类型3')
              order by dbms_random.value
            )
       where rownum <= 70
      union all
      select type1,type2
       from(
            select type1,type2
              from tbname
             where type2 = '选择题'
               and type1 in('类型1','类型3')
              order by dbms_random.value
            )
       where rownum <= 30;
      

  5.   

    感觉6楼的只是把 我外面的条件 放在了里面的 select中 充当条件       本人SQL很菜  求解释