萬盛學電腦網

 萬盛學電腦網 >> 數據庫 >> mysql教程 >> SQL分組排序去重復的小實例

SQL分組排序去重復的小實例

這篇文章介紹了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 這裡是按什麼分組, 注意一下。

copyright © 萬盛學電腦網 all rights reserved