Probably need to clarify what is meant by "Latest course" ?
Does this mean the date someone enrolled in a Course ?
I could see this being relevant if users are self-enrolling, but if it's using Cohorts or external enrolments you probably already have the value anyway.
And what happens if a user is enrolled in two or more courses ? Maybe with different durations ?
I would think it's going to be a lot easier to develop the query to provide data from all courses, because the conditions / filtering you are trying to incorporate are quite complex. You could always extract big data, and then Filter in Excel / Calc or similar ?
Stu