我需要创建具有以下结构的表:SQL创建周期为几个星期的表 - 在月末有中断(Oracle)
calendar week;周开始日期;周结束日期
其中包含从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)这样的表?
谢谢
问候
纳丁
什么的Oracle版本? – 2009-12-02 23:14:00
版本是Oracle 10g – hihops 2009-12-07 19:35:12