答案 0 :(得分:1)
您希望按每个年龄段的最长时间订购。大多数数据库都支持ANSI标准窗口函数,因此您可以这样做:
select t.*
from t
order by max(timestamp) over (partition by age) desc,
age,
timestamp desc;
在"数据库"那不是(MS Access,SQLite,MySQL):
select t.*
from t join
(select age, max(timestamp) as maxts
from t
group by age
) tt
on t.age = tt.age
order by maxts desc, age, timestamp desc;