I am querying a Ora Db 10g table that holds the current Week value and current Year value.
Require a query capturing upto 14 weeks future data so therefore where the current week number plus 14 = 52 i'll need to increment the year number by 1 and set the week number to 01 before then going onto capture the associated data for each week.
I've think (!) i need to use DECODE and SUM not convinced that it's the correct way and struggling with the structure, so in simple terms:
If CurrentWeek = 41 then
Year = Year + 1 and Week = 01
ElseIf Current Week = 42 then
Year = Year + 1 and Week = 02
Else Year = Year and Week = Week
My attempt is:
Expand|Select|Wrap|Line Numbers
- SELECT DECODE('CurrentWeek', 41, SUM(CurrentYear +1), 'CurrentYear') AS YEAR, DECODE('CurrentWeek', 41, 01), 'CurrentWeek') AS week
- FROM VENDOR.tblCALENDAR