vendredi 2 janvier 2015

if or case statement with nested select statement

I have three columns member_ID, Effective_Date and Termination_Date. Member_ID is not unique.


I would like to do the following:



Select
If Termination_Date is null
then select min(Effective_date)
where current_record.member_ID = enrollment.member_ID
having min(enrollment.effective_date) <> current_record.effective_date
Else 2014-12-31
end as updated termination date
from enrollment
where Current_Record.Member_ID = Enrollment.Member_ID
from enrollment

Aucun commentaire:

Enregistrer un commentaire