在Oracle中怎样查询前10条记录?

在Oracle中怎样查询前10条记录?,第1张

根据时间条件排序,取前十条和后十条。

1、有时间字段, 根据时间条件排序,取前十条和后十条

(1)前十条:

select * from (select * from tab_name a order by date_col )

where rownum<11

(2)后十条:

select * from (select * from tab_name a order by date_col  desc)

where rownum<11

2、没有时间字段, 直接根据物理存储顺序,取前十条和后十条

(1)前十条:

select * from (select * from tab_name a order by rownum)

where rownum<11

(2)后十条:

select * from (select * from tab_name a order by rownuml  desc)

where rownum<11

mysql中排序取第十个数据如下,shell 脚本中连接数据库执行mysql 命令,在 shell 脚本中,去链接数据库,并执行相关的命令的步骤如下:首先使用 touch 命令创建个文件, 使用 chmod 赋给这个文件执行权限。


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/sjk/6694485.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-26
下一篇 2023-03-26

发表评论

登录后才能评论

评论列表(0条)

保存