Lee R Liddick Jr asked on # SQL query and if statement

In my where statement I need to check two areas, if the first isn't populated, check the other.

if a.C_EFF_DT is NOT NULL then a.C_EFF_DT < date(current date - 6 months)

if a.C_EFF_DT is NULL then b.C_EFF_DT < date(current date - 6 months)

So basically if the first C_EFF_DT is null then check the second C_EFF_DT, if it has a date, then check it and don't worry about the second date.

if a.C_EFF_DT is NOT NULL then a.C_EFF_DT < date(current date - 6 months)

if a.C_EFF_DT is NULL then b.C_EFF_DT < date(current date - 6 months)

So basically if the first C_EFF_DT is null then check the second C_EFF_DT, if it has a date, then check it and don't worry about the second date.

DatabasesSQL

Log in or sign up to see answer

Become an EE member today7-DAY FREE TRIAL

Members can start a 7-Day Free trial then enjoy unlimited access to the platform

or

Learn why we charge membership fees

We get it - no one likes a content blocker. Take one extra minute and find out why we block content.

Not exactly the question you had in mind?

Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.

ask a questionLog in or sign up to see answer

Become an EE member today7-DAY FREE TRIAL

Members can start a 7-Day Free trial then enjoy unlimited access to the platform

or

Learn why we charge membership fees

We get it - no one likes a content blocker. Take one extra minute and find out why we block content.

Not exactly the question you had in mind?

Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.

ask a questionLee R Liddick Jr

I didn't want this in CF...I am doing this in SAS SQL. The case end in the where statement didn't work. It doesn't like the less than sign...the query gives an error in the log.

Get an unlimited membership to EE for less than $4 a week.

Unlimited question asking, solutions, articles and more.

Lee R Liddick Jr

I've requested that this question be closed as follows:

Accepted answer: 0 points for leerljr68's comment #a39901107

for the following reason:

Accepting own comment since I figured it out myself with no assistance from the other expert comments. Thank you.

Accepted answer: 0 points for leerljr68's comment #a39901107

for the following reason:

Accepting own comment since I figured it out myself with no assistance from the other expert comments. Thank you.

Get an unlimited membership to EE for less than $4 a week.

Unlimited question asking, solutions, articles and more.

Lee R Liddick Jr

I'm awarding points to those who responded.

This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.

rwheeler23

Lee R Liddick Jr

Even though I answered my own question, I'm awarding points for taking the time to respond. Thank you all.