是否可以使用ROWNUMBER()过滤掉具有多个rownumber的记录。
E.g。
或
代码:
SELECT *
FROM
(SELECT
ID, blah, blah2,
ROWNUMBER() OVER(PARTITION BY ID ORDER BY blah, blah2) AS rn
ORDER BY ID)
WHERE rn IS ONLY 1;
答案 0 :(得分:0)
SELECT *
FROM
(SELECT
ID, blah, blah2,
ROW_NUMBER() OVER(PARTITION BY ID ORDER BY blah, blah2) AS rn
FROM table_name
WHERE ...
)
WHERE rn = 1;