sql分组查询每组的第一条数据或者按某个字段排序后 查出每组的第一条数据。
select * from(select row_number()
over(partition by 分组字段 order by 排序字段 desc) as rownum,*
from (SELECT
*
FROM
表名
)as H1
) as H where H.rownum =
1
sql分组查询每组的第一条数据或者按某个字段排序后 查出每组的第一条数据。
select * from(select row_number()
over(partition by 分组字段 order by 排序字段 desc) as rownum,*
from (SELECT
*
FROM
表名
)as H1
) as H where H.rownum =
1
评论区