例子,sql分组排序并去除重复的方法。
复制代码 代码示例:
SELECT
*
FROM
(
SELECT
userid,
classid,
remark,
ROW_NUMBER () OVER (
PARTITION BY userid,
classid
ORDER BY
addtime DESC
) AS row_bank
FROM
Eng24VIPCourseIntention
) AS ta
WHERE
row_bank = 1
注意, PARTITIONBYuserid,classid 这里是按什么分组。