Solved

IF function

Posted on 2011-03-23
6
227 Views
Last Modified: 2012-05-11
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
0
Comment
Question by:parpaa
  • 3
  • 2
6 Comments
 
LVL 24

Expert Comment

by:jimyX
ID: 35196501
You can use case:
(case deliquency_date > 21 then "YES" else "No" end)
0
 
LVL 24

Expert Comment

by:jimyX
ID: 35196517
Sorry the syntax is:
case deliquency_date when deliquency_date > 21 then "YES" else "No" end
0
 
LVL 24

Accepted Solution

by:
jimyX earned 500 total points
ID: 35196523
Final:
case when deliquency_date > 21 then "YES" else "No" end
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:parpaa
ID: 35196529
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '>'.
0
 

Author Comment

by:parpaa
ID: 35196536
it was 'Yes'... sorted ..
thanks Jimy
0
 
LVL 50

Expert Comment

by:Lowfatspread
ID: 35196591
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')

0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

I have written a PowerShell script to "walk" the security structure of each SQL instance to find:         Each Login (Windows or SQL)             * Its Server Roles             * Every database to which the login is mapped             * The associated "Database User" for this …
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now