• Well I finally got it to work with the help of a co-worker...here is the code

     

     

    previous_discharge_date  = (SELECT MAX(ISNULL(referral_ref.dischargedate, '')) as previous_discharge_date

        FROM

         referral as referral_ref

        WHERE

         referral_ref.dischargedate  <>'2078-12-31 00:00:00'

         AND referral.memid   = referral_ref.memid),

     

    I was making it way more complex than it needed to be...

     

    Thanks to everyone for the help

     

    Leeland