select   *   from   table1 from (select   field2   from   table2 order by field2 desc) as table 加order by 的時候會出錯。不知各位有沒有好的辦法。一定要order子句,不能刪除。有沒有好的辦法   

解决方案 »

  1.   


    select  *  from  table1 from (select  field2  from  table2 order by field2 desc) as table 两个from当然出错。
    是不是这样select  *  from (select  field2  from  table2 order by field2 desc) as table 
      

  2.   

    select  *  from  (select  TOP 100 PERCENT field2  from  table2 order by field2 desc) as tableName
      

  3.   


    select  *  from (select  field2  from  table2 order by field2 desc) as a
      

  4.   

    select  *  from  (select  top 1 field2  from  table2 order by field2 desc) as table
      

  5.   

    select  *  from (select  field2  from  table2 order by field2 desc) as Tab
      

  6.   

    字查询使用ORDER BY 会提示要指定TOP
      

  7.   


    select  *  from (select  field2  from  table2 ) as [table ]
    order by field2 desc??
      

  8.   

    子查询不能用order by, 因为在sql执行时到order by这句返回的是指针, 并没有真正返回tmp table.
    如果有top n 的话, 可以有order by.
      

  9.   


    select  *  from  table1 from....select  *  from (select  field2  from  table2 order by field2 desc) as Tab
      

  10.   

    order by 不能放在子句里。
    select  *  from (select  field2  from  table2) as table
    order by table.field2 desc
      

  11.   

    order by 是不允许放子查询的,除非加top。
    一般说来,在内层排序可以拿到外不来排序。select  *  
    from  table1,(select  field2  from  table2) as [table]
    order by [table].field2 desc
      

  12.   

    那個我打錯的。子查詢不能加order的
      

  13.   

    这个oracle的怎么解决 非常郁闷
      

  14.   

    1、首先子查询中可以使用order by!
    2、楼主的问题,我觉得是 as 用法错误 ,跟order by 是否应用子查询没有关系。修改成为即可 select * from table1 from (select field2 from table2 order by field2 desc) table
    3、下面截取官档一段order by 和 rownum 一起用的范例!
    If you embed the ORDER BY clause in a subquery and place the ROWNUM condition in the top-level query, then you can force the ROWNUM condition to be applied after the ordering of the rows. For example, the following query returns the employees with the 10 smallest employee numbers. This is sometimes referred to as top-N reporting:SELECT * FROM
       (SELECT * FROM employees ORDER BY employee_id)
       WHERE ROWNUM < 11;