Oracle中关于日期between and的使用方法,求助

蜗牛@路上 2011-07-27 02:45:21
Oracle中,如何获得下表表中数据
YM DD NUM
201107 26 11
201107 27 14
201107 28 19
201107 29 21
201107 30 61
201107 31 71

201108 1 24
201108 2 42
201108 3 204
201108 4 12
201108 5 124


如何获得2011年7月26号到2011年8月5号的NUM数据

注:YM DD 都是NUM类型
...全文
1027 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
蜗牛@路上 2011-07-27
  • 打赏
  • 举报
回复
这种方法不大适合我的程序,不过还是谢谢你哈[Quote=引用 2 楼 horizonlyhw 的回复:]
SQL code

select ym,dd,num
from tab
where ym = 201107
and DD > 26

union all

select ym,dd,num
from tab
where ym = 201108
and DD < 5
[/Quote]
蜗牛@路上 2011-07-27
  • 打赏
  • 举报
回复
恩,好方法!!!谢谢哈[Quote=引用 1 楼 benchim888 的回复:]
SQL code

select num
from table_name
where ym||lpad(dd,2,'0') between '20110726' and '20110805';
[/Quote]
horizonlyhw 2011-07-27
  • 打赏
  • 举报
回复

select ym,dd,num
from tab
where ym = 201107
and DD > 26

union all

select ym,dd,num
from tab
where ym = 201108
and DD < 5
BenChiM888 2011-07-27
  • 打赏
  • 举报
回复

select num
from table_name
where ym||lpad(dd,2,'0') between '20110726' and '20110805';

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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