select * from (select id,time  from a union select id time from b) a order by id

解决方案 »

  1.   

    select * from (select id,time  from a union select id time from b) a order by time
    sorry
    刚才没有看要求
      

  2.   

    select id,time  from a union select id time from b 
    order by time;
      

  3.   

    select id,time  from a union select id ,time from b order by id
      

  4.   

    应该是select id,time  from a union select id ,time from b order by time
    只有在 UNION 语句的结尾,才允许使用 ORDER BY  子句以定义最终结果的顺序。不能在组建 UNION 语句的单独查询中使用这些子句。
      

  5.   

    select id,time  from a union select id ,time from b 
    order by time
      

  6.   

    --如果要改变这个默认排序,就用:--将结果按time排序
    select * from(
    select id,time  from a union select id time from b
    ) a order by time
      

  7.   

    在最后一句加上 order by time
      

  8.   

    以下两条语句有什么不同吗?
    select * from (select id,time  from a union select id time from b) order by time;select * from (select id,time  from a union select id time from b)  a   order by time;
      

  9.   

    个人感觉没有什么区别可以这样写:
    select * from (select id,time  from a union select id time from b) a order by a.time
      

  10.   

    执行上效果是一样的,
    想知道
    select * from (select id,time  from a union select id time from b)  a   order by time;
    中, 多出的 a 怎么解释执行的?
      

  11.   

    回复人: netcar(netload) ( ) 信誉:100  2003-12-25 12:29:00  得分:0 
     
     
      个人感觉没有什么区别可以这样写:
    select * from (select id,time  from a union select id time from b) a order by a.time
     ----------------------------------------------------------老兄,你这么写是不对的 ,直接用order by time就行。
     
      

  12.   

    可以这样写:
    select * from (select id,time  from a union select id,time from b) a order by a.time--可以的