【发布时间】:2009-12-02 23:08:51
【问题描述】:
我需要创建一个结构如下的表:
日历周;周开始日期;周末结束日期
其中包含从 2007 年开始到当前一周的所有周。
特别之处在于,当月末在一周内时,该周被分成两部分 - 一条记录的开始日期是一周的开始日期,结束日期是一周的最后一天月,以及一个包含一周剩余日期的记录(开始日期是新月份的第一天,结束日期是一周的最后一天)。
示例(一周的开始是星期一):calendar week; week start date; week end date; ... 2009 cW48; 23.11.2009; 29.11.2009 --"normal" week with 7 days, beginning monday and ending sunday 2009 cW49; 30.11.2009; 30.11.2009 --first part of the CW49, which ends at last day of the month 2009 cW49; 01.12.2009; 06.12.2009 --second part of the CW49, which begins at fist day of the new month 2009 cW50; 07.12.2009; 13.12.2009 --"normal" week, without a monthly break ...
如何在Oracle(SQL或PL SQL)中创建这样的表?
【问题讨论】: