select temp.*
from (SELECT *,Row_Number() OVER (partition by 分组字段 ORDER BY 排序字段 desc) as rank FROM user_task_tb where 条件) temp
where rank = 1
sqlserver分组查询,获取最新一条数据
最新推荐文章于 2024-06-30 21:16:43 发布
select temp.*
from (SELECT *,Row_Number() OVER (partition by 分组字段 ORDER BY 排序字段 desc) as rank FROM user_task_tb where 条件) temp
where rank = 1