Link to home
Start Free TrialLog in
Avatar of parpaa
parpaa

asked on

IF function

Hi all,

PFA the structure of my source table, now I want to add new column (OverDue) based the below logic
if (deliquency_date>21 ,"YES","No")
How could I achieve this?
Any suggestions are highly appreciated.

Thanks in advance
TM-Dashboard.xlsx
Avatar of jimyX
jimyX

You can use case:
(case deliquency_date > 21 then "YES" else "No" end)
Sorry the syntax is:
case deliquency_date when deliquency_date > 21 then "YES" else "No" end
ASKER CERTIFIED SOLUTION
Avatar of jimyX
jimyX

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of parpaa

ASKER

Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '>'.
Avatar of parpaa

ASKER

it was 'Yes'... sorted ..
thanks Jimy
create view myview
 as select col1,col2,col3,...
   ,case when delinquency_date > 21 then 'yes' else 'no' end as newcolname
from yourtablename


then query myview instead of the table...

or

alter table
add newcolname coalesce(case when delinquency_date > 21 then 'yes' else 'no' end,'no')