单表查询。一个字段有多条记录,要取时间最老的一条。新手啊。请教下大家。谢谢

解决方案 »

  1.   

    select * from yourTable a where exists
    (
       select 1 from yourTable b where a.cdate>b.cdate
    )
      

  2.   

    select *
    from tb_sp01 
    where enter_date=
    (select mAX(t.enter_date) from tb_sp01 t)
    enter_date 日期字段
      

  3.   

    select * from tableName where field=? order by date;然后取第一条。逻辑:根据你的字段查询,然后针对时间排序(从小到大)。取第一条即可!
      

  4.   

    按时间排序(从小到大)。取第一条即可,select * from table where rownum = 1 order by 时间
      

  5.   

    4楼的貌似不行的SELECT * FROM (SELECT * FROM abc ORDER BY 字段)WHERE ROWNUM=1 ;
      

  6.   


    select * from table_name t 
             where t.end_date = 
                   (select max(d.end_date) from table_name d 
                                           --假设你要的一个字段有多条记录的字段是table_id
                                           group by d.table_id having coutn(1) > 1); 
      

  7.   

    select *
      from table1 t
     where rowid =(select max(rowid)  --max 或min
                     from table1 t2
                    where t.field  = t2.field)这样可以么,用rowid的大小来判断是最近插入还是之前插入的?