SQL分组排序去重复的小实例_MsSql

  • A+
所属分类:MSSQLSERVER

复制代码 代码如下:

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 这里是按什么分组, 注意一下。

  • 我的微信
  • 这是我的微信扫一扫
  • weinxin
  • 我的微信公众号
  • 我的微信公众号扫一扫
  • weinxin

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: