First, I am not much of a database person. I usually just develop Crystal Reports off of databases. So, I apologize in advance if I'm not being clear.
We have a huge stored procedure set up for one of our reports. There are tons of DECODE statements. There is a set of DECODE lines that are related and are giving me the fields I need. New logic needs to be added so that when it is prior to a certain year, this logic stays as is, otherwise it needs to follow a set of different logic.
Oversimplified, what I want is this:
If Year > 2005
Then X
Else Y
However, Y = 10 sets of DECODE statements that define 10 values. Likewise, X would also need to define 10 values. I would prefer not to re-write the set in Y because each one of the 10 values can consist of 169 DECODEs. It's just messy.
I tried
but I kept getting missing keyword. So, any help would be greatly appreciate, and if I need to explain anything further let me know.
We have a huge stored procedure set up for one of our reports. There are tons of DECODE statements. There is a set of DECODE lines that are related and are giving me the fields I need. New logic needs to be added so that when it is prior to a certain year, this logic stays as is, otherwise it needs to follow a set of different logic.
Oversimplified, what I want is this:
If Year > 2005
Then X
Else Y
However, Y = 10 sets of DECODE statements that define 10 values. Likewise, X would also need to define 10 values. I would prefer not to re-write the set in Y because each one of the 10 values can consist of 169 DECODEs. It's just messy.
I tried
Code:
CASE
WHEN Year > '2005'
THEN DECODE(a,b,c,0) value1, DECODE (c,d,e,0) value2,
ELSE DECODE(a,b,DECODE(z,y,x,0),0) value1, DECODE(c,d,DECODE(m,n,o,0),0) value2,
END