我的查询:
select
SUM(payments.paid_amt) as paid_amt,
SUM(payments.copay_amt) as copay_amt,
SUM(payments.CO_INSURANCE_AMT) as co_ins_amt,
SUM(payments.PATIENT_RESP_AMT) as patient_resp_amt,
accession.ACCESSION_ID
from
[F_PAYOR_PAYMENTS_monthly] payments
join F_ACCESSION_daily accession
on accession.ACCESSION_ID=payments.ACCESSION_ID
where accession.XIFIN_LOAD_DATE between '20111201' and '20111231'
group by accession.ACCESSION_ID
这是加入数据的样本:
这是付款:
我的问题是 SAME 加入的 SAME 付款被多次计算
我的问题是如何确保对特定加入的付款只计算一次?
之间的关系payments ---> accession
是many to 1
非常感谢您的指导。
我对上述示例的期望是:
AA895325, sum(paid_amt), sum(copayt_amt), etc..