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

oracle 查询一条记要中两个时间的所有日期

2013-03-25 
oracle 查询一条记录中两个时间的所有日期test表结构和数据如下:idratestart_dateend_date10.82013-02-012

oracle 查询一条记录中两个时间的所有日期
test表结构和数据如下:
id     rate    start_date     end_date
1       0.8    2013-02-01     2013-02-15
2       0.6    2013-02-16     2013-02-28
3       0.4    2013-03-01     2013-03-10

查出每条记录的start_date 和end_date之间的所有日期和对应的rate  结果:
id      rate      date
1       0.8     2013-02-01
1       0.8     2013-02-02
1       0.8     2013-02-03
......
3      0.4     2013-03-10


SQL:

select a.id,rate, a.start_date, a.end_date, a.start_date+b.dis-1 h fromtest a,(select rownum dis from     (select max(end_date-start_date)+1 gap from test)connect by rownum<=gap) bwhere a.end_date>=a.start_date+b.dis-1order h

热点排行