我需要創建具有以下結構的表: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