sqlserver去重只查一条数据

SELECT ModifiedBy ,IDCardNo
FROM (
SELECT ROW_NUMBER() over (PARTITION BY IDCardNo ORDER BY dt DESC) AS num ,
ModifiedBy,
IDCardNo
FROM test
WHERE ItemNo=@itemno AND ActiveFlag='Y'
) AS t WHERE t.num=1

posted @ 2021-08-26 16:54  金虹巴巴  阅读(384)  评论(0编辑  收藏  举报