ORACLE中取得分组之后,每组数据中(多个字段)不重复的前10条记录,并且按时间排序。

2024-12-15 22:21:20
推荐回答(1个)
回答1:

SELECT *
FROM (SELECT T2.*, ROW_NUMBER()
OVER(PARTITION BY MAE_NAME ORDER BY TIME_STAMP_END DESC) AS RN2 FROM
(SELECT T1.*,
ROW_NUMBER() OVER(PARTITION BY MAE_NAME, PRODUCT, OP, VERSION ORDER BY TIME_STAMP_END DESC) AS RN1
FROM CONDITION_CSV T1) WHERE RN1 = 1) T2
WHERE RN2 < 11