我的表格如下:
clm_id process_id note
N500 11 leg fracture
N500 12 leg fracture
N500 13 delivery
N500 14 headache
N501 5 surgery
N501 6 fever
N501 7 prostate
N501 8 prostate
这是理想的结果:
claim_id process_id note
N500 11 leg fracture
N500 12 leg fracture
N501 7 prostate
N501 8 prostate
我该怎么做呢?
答案 0 :(得分:1)
一个快速选项是使用sum() over ()
示例强>
;with cte as (
Select *
,Cnt = sum(1) over (Partition By clm_id,note)
From YourTable
)
Select clm_id
,process_id
,note
From cte
Where Cnt>1
<强>返回强>
clm_id process_id note
N500 11 leg fracture
N500 12 leg fracture
N501 7 prostate
N501 8 prostate