Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Align arbitrary time periods to calendar quarter

$
0
0
Hello,
Please help me with the following problem.

Here is my data:
I have a table UTIL with the following columns
create table UTIL
(
REF_LINE_ID number (PK)
PERIOD_START number
PERIOD_END number
GOODS_QTY number
)

Data sample:
REF_LINE_ID PERIOD_START PERIOD_END GOODS_QTY
83939 20110101 20110431 11
83940 20111115 20111130 11
83941 20111201 20111220 11
84197 20111001 20111131 61
84198 20111101 20111130 61
84199 20111201 20111231 60

As you can see period_start and period_end dates can cross multiple quarters or months or might represent partial month. So one line in this table might become more than one due to multiple quarters covered in period

Problem:
I need to stamp respective quarters on every line, split it if period start and end covers more than one quarter and allocate goods_qty based on ratio of days in every split period over total # of days in the original period.

I am not sure if I stated the problem clearly enough, please let me know.

Thanks a lot in advance!
Peter.

Viewing all articles
Browse latest Browse all 13329

Trending Articles