我有这个查询
SELECT
patientid,
practiceid,
visitcount
FROM
(
SELECT
patientid,
practiceid ,
visitcount,
RANK() OVER (PARTITION BY patientid ORDER BY visitcount DESC) as Rank
FROM
aco.patients_practices
WHERE practiceid in (select id from aco.practices where parentaco = 30982) and isprimary = 0
) AS A
WHERE
Rank = 1
以下是一些结果
patientid practiceid 就诊次数 157053 30976 6 158463 30974 2 187772 30973 15 187797 30971 1 187797 30975 1
请注意,最后 2 个患者 ID 是相同的,并且访问次数相同,因此排名相同。如何从输出中完全省略这些具有相同等级的记录?
谢谢!