(442条消息) ROW_NUMBER() OVER(PARTITION BY)函数_rownum over_EilW的博客-CSDN博客
select * from
(
SELECT *,
ROW_NUMBER() OVER(PARTITION BY id ORDER BY create_time DESC) AS rowNum
FROM 表A as c
) d where d.rowNum<=2
这条sql的意思是根据id进行分区,并以create_time进行倒序排序,查出每个id对应的记录中创建时间(create_time)最新的2条记录。