select
substr(output_svycode_NM,1,2) as SI,
SUM(PROCESSING_BATCHSIZE_QTY) AS LOADS,
to_char(batch_release_dt,'IW') WK
from
PARTS_DATABSE
where
(OUTPUT_SVYCODE_NM like '29%')
and batch_release_dt >='02-FEB-09'
and batch_release_dt <'27-DEC-09'
group by
substr(OUTPUT_SVYCODE_NM,1,2),
to_char(batch_release_dt,'IW')
This gives me result like following
SI LOADS WK
-- ----------- --
29 377068 06
29 512180 07
29 177249 08
29 257117 09
29 391693 10
29 242608 11
What i would like is something like below
SI Week_Sent LOADS WK Expected Return (sent +8days)
-- ---------- ------ ----- ---------------
29 Feb2-Feb8 377068 06 Feb10-Feb16
29 Feb9-Feb15 512180 07 Feb17-Feb23
29 Feb16-Feb22 177249 08 Feb24-Mar02
29 Feb23-Mar01 257117 09 Mar03-Mar09
29 Mar02-Mar08 391693 10 Mar10-Mar16
29 Mar09-Mar15 442608 11 Mar17-Mar22
substr(output_svycode_NM,1,2) as SI,
SUM(PROCESSING_BATCHSIZE_QTY) AS LOADS,
to_char(batch_release_dt,'IW') WK
from
PARTS_DATABSE
where
(OUTPUT_SVYCODE_NM like '29%')
and batch_release_dt >='02-FEB-09'
and batch_release_dt <'27-DEC-09'
group by
substr(OUTPUT_SVYCODE_NM,1,2),
to_char(batch_release_dt,'IW')
This gives me result like following
SI LOADS WK
-- ----------- --
29 377068 06
29 512180 07
29 177249 08
29 257117 09
29 391693 10
29 242608 11
What i would like is something like below
SI Week_Sent LOADS WK Expected Return (sent +8days)
-- ---------- ------ ----- ---------------
29 Feb2-Feb8 377068 06 Feb10-Feb16
29 Feb9-Feb15 512180 07 Feb17-Feb23
29 Feb16-Feb22 177249 08 Feb24-Mar02
29 Feb23-Mar01 257117 09 Mar03-Mar09
29 Mar02-Mar08 391693 10 Mar10-Mar16
29 Mar09-Mar15 442608 11 Mar17-Mar22