If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

Conditon syntax in SQL

Started by cognosun, 04 Feb 2013 06:18:22 AM

Previous topic - Next topic

cognosun

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.

CognosPaul

#1
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.