写错了,应该是不能这样写:
select *
from test
where col2 = 
(select max(col2)
from test
where rownum=1)

解决方案 »

  1.   

    也不可以这样写:
    select *
    from
    (select *
    from test
    order by col2 desc)
    where rownum = 1
    总之是不要出现两个SELECT
      

  2.   

    select * from test where rownum=1 order by col2 desc;
      

  3.   

    select * from 
    (select * from test order by col2 desc)
    where rownum=1
      

  4.   

    select * from test where col2 = (select max(col2) from test) and rownum=1;
      

  5.   

    to  zhpsam109(昊子鳖鳖) : 你这种显然是错误的啊
      

  6.   

    select * from test where col2 = (select max(col2) from test) and rownum=1;加上 and rownum=1 是确保只返回一条。适用于最大值多个的情况
      

  7.   

    不好意思,我提问的时候写错了,
    不能这样写
    select *
    from test
    where col2 = 
    (select min(col2)
    from test)
    and rownum=1
    我的意思是一个SQL语句中不要出现两个SELECT,且能达到要求
      

  8.   

    我的意思是一个SQL语句中不要出现两个SELECT,且能达到要求------------------------------------------------------
    楼主这个要求也太那个了,不过也有办法select distinct first_value(col1) over(order by col2 desc) col1,
           first_value(col2) over(order by col2 desc) col2,
           first_value(col1) over(order by col2 desc) col3
    from test;
      

  9.   

    写错了点:(select distinct first_value(col1) over(order by col2 desc) col1,
           first_value(col2) over(order by col2 desc) col2,
           first_value(col3) over(order by col2 desc) col3
    from test;