select min(begdate),enddate
from (
select begdate,
enddate
from sometable
where enddate = (
select max(enddate)
from sometable
)
)
group by
enddate
above will work for Oracle and DB2