Hi,
We use Oracle SQL.
I got a column ( a) with "timestamp" data type and another column (b) with 'number' data type.
How shall i write a condition...
if year value in 'a' = 2013 then year value in 'b' is 2012 ( a-1)
if year value in 'a' = 2012 then year value in 'b' is 2011 ( a-1)
Many thanks in advance.
You need to filter all rows where b is equal to year(a)-1? You say that b is numeric, do you mean something like 20120101 or 2012?
Try doing something like
substr(to_char([b]),1,4) = to_char(add_months([a],-12),'yyyy')
EDIT: I forgot that [b] is actually a forum tag for bold.