in your subquery, you have GROUP BY cba_id
this means it will produce one aggregate row per cba_id
(that's what GROUP BY goes -- it aggregates a bunch of detail rows into one aggregate row)
naturally, for each distinct cba_d, the max(cba_id) is going to be that value!!!
it would be like asking what is the maximum employee id for each employee, where each employee has only one employee id
perhaps you could explain in words what you're trying to do?
