Link to home
Start Free TrialLog in
Avatar of Lee R Liddick Jr
Lee R Liddick JrFlag for United States of America

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.
SOLUTION
Avatar of plusone3055
plusone3055
Flag of United States of America image

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
SOLUTION
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 Lee R Liddick Jr

ASKER

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.
SOLUTION
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
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.
ASKER CERTIFIED SOLUTION
Avatar of _agx_
_agx_
Flag of United States of America image

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
I'm awarding points to those who responded.
Even though I answered my own question, I'm awarding points for taking the time to respond.  Thank you all.