我正在尝试根据以下内容获取所有重复的记录:
accession_id,
check_num,
procedure_code,
paid_amt,
此查询将返回上述内容以及这些字段重复的次数。
但是,我只想返回不止一次发生的那些。
select
ACCESSION_PAYMENTS_DAILY_KEY,
accession_id,
check_num,
procedure_code,
paid_amt,
row_number()
over
(partition by accession_id, check_num,procedure_code,paid_amt order by ACCESSION_PAYMENTS_DAILY_KEY) as occurrence
from [MILLENNIUM_DW_DEV].[dbo].[F_PAYOR_PAYMENTS_DAILY]
where PROCEDURE_CODE is not null
and PAID_AMT>0
当我将过滤条件添加occurrence>1
到上述查询时,我收到此错误:
Msg 207, Level 16, State 1, Line 13
Invalid column name 'occurrence'.
如果记录不止一次,我如何才能返回记录?