IT大拿好:
select count(*) from t_users where operatedate=to_date('2011-02-16 00:00:00','yyyy-mm-dd hh24:mi:ss'); -- 57
select count(*) from t_users where operatedate=to_date('2011-02-15 00:00:00','yyyy-mm-dd hh24:mi:ss'); --38
select count(*) from t_users where operatedate=to_date('2011-02-14 00:00:00','yyyy-mm-dd hh24:mi:ss'); --76如果用union连接查询,
select count(*) from t_users where operatedate=to_date('2011-02-16 00:00:00','yyyy-mm-dd hh24:mi:ss') union
select count(*) from t_users where operatedate=to_date('2011-02-15 00:00:00','yyyy-mm-dd hh24:mi:ss') union 
select count(*) from t_users where operatedate=to_date('2011-02-14 00:00:00','yyyy-mm-dd hh24:mi:ss') 结果如下:
38
57
76查询结果会排序,现在怎么设置 可以不让其排序,安装57,38,76来排序,谢谢大家!

解决方案 »

  1.   

    oracle本身就是无序的,不用设置不排序!
      

  2.   

    我没有设置排序,union查询后  就排序了,谢谢
      

  3.   

    select count(*) as num,1 as display from t_users where operatedate=to_date('2011-02-16 00:00:00','yyyy-mm-dd hh24:mi:ss') union
    select count(*) as num,2 as display from t_users where operatedate=to_date('2011-02-15 00:00:00','yyyy-mm-dd hh24:mi:ss') union 
    select count(*) as num,3 as display from t_users where operatedate=to_date('2011-02-14 00:00:00','yyyy-mm-dd hh24:mi:ss')  
    order by display
      

  4.   

    UNION在进行表链接后会筛选掉重复的记录,所以在表链接后会对所产生的结果集进行排序运算,删除重复的记录再返回结果。而UNION ALL只是简单的将两个结果合并后就返回
    从效率上说,UNION ALL 要比UNION快很多,所以,如果可以确认合并的两个结果集中不包含重复的数据的话,那么就使用UNION ALL
      

  5.   

    直接order by会报错,需要再套一层