有3个字段,id,time_stamp,group_id需要按照group_id分组group_id查询time_stamp最大的id的值。
我刚开始想用select id,max(time_stamp) from t group by group_id 但是发现那个id不对,请问该怎么写呢?
我刚开始想用select id,max(time_stamp) from t group by group_id 但是发现那个id不对,请问该怎么写呢?
from tb A
where not exists (select 1 from tb B where A.id<B.id and A.group_id=B.group_id)
[征集]分组取最大N条记录方法征集,及散分....