select a.* from Topic as a left outer join (select tid, max(Data) as Data from Reply group by tid ) as b on a.id=b.tid order by b.Data desc
典型的分组排序取每组第一,方法多种
select * from Topic A
join
(
select TID from Reply order by ID desc
) B
on A.ID=B.TID
order by B.TID
因为你reply表中没有时间这个字段,我假设你的ID是自增列的..就用ID来排序了,如果有时间列的话,应该用时间列来排序.