如何查找表中的最后一条记录?

darthin 2003-10-27 10:57:12
如何sql语句查找表中的最后一条记录?谢谢
...全文
247 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
timepalette 2003-11-11
  • 打赏
  • 举报
回复

to beckhambobo(beckham) 你的那个语句出错:

SQL> select * from tjh_test where rowid=(select rowid from (select last_value(rowid) over(order by r
ownum) rowid from tjh_test) where rownum=1);
select * from tjh_test where rowid=(select rowid from (select last_value(rowid) over(order by rownum
*
ERROR 发生在第 1 行:
ORA-00923: 未找到预期 FROM 关键字



to l2g32003(leeshow)但是时间也只能精确到秒啊!!!要是同一秒插多条呢??
Frewin 2003-10-28
  • 打赏
  • 举报
回复
up
l2g32003 2003-10-28
  • 打赏
  • 举报
回复
不可能的 你上 asktom上看看
除非表中有 时间 sequence 的字段标示先后
smallcrocodile 2003-10-27
  • 打赏
  • 举报
回复
什么最后一条?
ORACLE里的记录没有前后分别
beckhambobo 2003-10-27
  • 打赏
  • 举报
回复
sorry:
select * from table_name where rowid=(select last_value(rowid) over(order by rownum) from table_name where rownum=1);
beckhambobo 2003-10-27
  • 打赏
  • 举报
回复
select * from table_name where rowid=(select last_value(rowid) from table_name);
beckhambobo 2003-10-27
  • 打赏
  • 举报
回复
rowid最大不一定最后记录
select * from table_name where rowid=(select rowid from (select last_value(rowid) over(order by rownum) rowid from table_name) where rownum=1);
hushuangyang 2003-10-27
  • 打赏
  • 举报
回复
select rowid,a.* from table_name a where rowid=(select max(rowid) from table_name);
rowid是最大的一条才是最近的记录。
djwdjw 2003-10-27
  • 打赏
  • 举报
回复
试一下下面的语句,应该可以:
select * from table_name where rowid=(select rowid from (select rowid from table_name order by rowid desc) where rownum=1)
我刚学Oracle,有什么问题请大家提出来,相互提高。

darthin 2003-10-27
  • 打赏
  • 举报
回复
我指得是 最后插入的一条记录

请问如何用sql语句查出来
hchcsdn 2003-10-27
  • 打赏
  • 举报
回复
查出来是第一条
djwdjw 2003-10-27
  • 打赏
  • 举报
回复
楼主说的是最后插入的一条记录吗?

17,086

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧