首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > oracle >

求sql,删除 最早日期的一条记录,如何写

2012-02-17 
求sql,删除 最早日期的一条记录,怎么写select*fromtableorderbytime查出来的第一条,删除掉请指教[解决办法

求sql,删除 最早日期的一条记录,怎么写
select   *   from   table   order   by   time
查出来的   第一条,删除掉
请指教

[解决办法]
delete from table where time =(select top 1 time from table order by time )
[解决办法]
晕了
delete from table where time in (select min(time) from table)
[解决办法]
delete from table where time in
(
select time from
(
select time from table order by time
)
where rownum = 1
)

[解决办法]
楼上的兄台,如果time是主键那么你的sql没有问题,可是如果不是呢?

改为下面就可以了:

delete from table where rowid in
(
select rowid from
(
select time from table order by time
)
where rownum = 1
);

楼主问题解决了记得给分啊 。

热点排行