--先根据A进行分组,再在组内根据B进行排序。rn<3取出每一类的头三条数据
SELECT *
FROM (SELECT T.B,
T.A,
ROW_NUMBER() OVER(PARTITION BY T.A ORDER BY T.B DESC) RN
FROM DUAL T)
WHERE RN <= 3;
时间: 2024-10-28 09:26:58
--先根据A进行分组,再在组内根据B进行排序。rn<3取出每一类的头三条数据
SELECT *
FROM (SELECT T.B,
T.A,
ROW_NUMBER() OVER(PARTITION BY T.A ORDER BY T.B DESC) RN
FROM DUAL T)
WHERE RN <= 3;