select max(data) from tbl where data between(data1 ,data2); 好想是这样的啊!

解决方案 »

  1.   

    select max(字段名) from 表名 where 字段名>    and    字段名<
      

  2.   

    SELECT MAX(time)
    FROM t_time
    WHERE time >= '2002-01-11' AND time <= '2002-01-15'
      

  3.   

        不好意思,忘了是在 PRO * C 中写的。我写的是这样:
      EXEC SQL SELECT TOP 1 NMJ_KANJKMK,KBN_IKAT_KEIJO 
      FROM RFM006D0
      WHERE YMD_YUKO_KIKN_STAT <= '02-01-01' AND YMD_YUKO_KIKN_FNSH >= '01-01-01'
      ORDER BY YMD_YUKO_KIKN_STAT DESC;
      

  4.   

    解决了,我是用 ORACLE 8 的,所以,不能用 TOP ,只能用 ROWNUM=1 这样。但还是要感谢你们!
      

  5.   

    请参考:
    create table test (a   date, b number(5));
    insert into test values(to_date('2001-01-14','yyyy-mm-dd'),1);
    insert into test values(to_date('2001-01-15','yyyy-mm-dd'),2);
    insert into test values(to_date('2001-01-16','yyyy-mm-dd'),5);
    insert into test values(to_date('2001-01-17','yyyy-mm-dd'),4);
    insert into test values(to_date('2001-12-17','yyyy-mm-dd'),3);
    commit;
    select * from test 
       where a = (
            select max(a) from test
                where a>=to_date('2001-01-14','yyyy-mm-dd')
                   and a<=to_date('2002-01-01','yyyy-mm-dd')
              );
              
      

  6.   

    ORDER BY XXXX DESC 就行了!
      

  7.   

    select * from test  where a>=to_date('2001-01-14','yyyy-mm-dd') and a<=to_date('2002-01-01','yyyy-mm-dd') and rownum = 1 order by a desc ;