[英]Populating future dates in oracle table
I have attached tables, product and date. 我已附上表格,产品和日期。 Lets say my product table has data till yesterday ie 05/31/2018 am trying to populate season table where I could do the calculation till 5/31/2018 where value = (value on same day last year/previous day last year) with Ch(a) and P(pen), however the data set was till 5/31/2018.
可以说我的产品表具有直到昨天的数据,即05/31/2018正在尝试填充季节表,在该表中我可以进行计算直到2018年5月31日,其中value =(去年同一天/去年前一天的价值) Ch(a)和P(pen),但是数据集截止到2018年5月31日。 my aim is to get data/calculation for 06/1/2018 till 12/31/2018 as well.
我的目标是获取2018年6月1日至2018年12月31日的数据/计算结果。 how do i get the data for these future dates as I have the data to calculate these future dates in prod table.
我如何获取这些未来日期的数据,因为我有数据可以在产品表中计算这些未来日期。
You can generate a series of dates using CONNECT BY subquery like this one: 您可以使用CONNECT BY子查询生成一系列日期,如下所示:
SELECT Start_date + level - 1 as my_date
FROM (
SELECT date '2018-01-01' as Start_date FROM dual
)
CONNECT BY Start_date + level - 1 <= date '2018-01-05'
Demo: http://www.sqlfiddle.com/#!4/072359/1 演示: http : //www.sqlfiddle.com/#!4/072359/1
| MY_DATE |
|----------------------|
| 2018-01-01T00:00:00Z |
| 2018-01-02T00:00:00Z |
| 2018-01-03T00:00:00Z |
| 2018-01-04T00:00:00Z |
| 2018-01-05T00:00:00Z |
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.