我收到错误“选定的非聚合值必须是关联组的一部分”
当我添加行“,current_date - pmnt_rlse_dt as “Days since Paid”时,我开始收到此错误
我知道这与 group by 有关,但我还没有弄清楚。
select ee.alias_last_nm || ', ' || ee.alias_first_nm as "Custodian"
,clm.i_sys_clm
,clm.c_clm as "Claim Number"
,clm.i_pol as "Policy Number"
,clm.n_lst as "Last Name"
,clm.n_fst as "First Name"
,clm.c_sta_clm as "Status"
,mx_dt as "Last Payment Date"
from ltc_p.vltc_clm_mo clm
left join (select indiv_sorce_syst_cd
,sorce_upc_indiv_id
,alias_last_nm
,alias_first_nm
from edw_p.upc_indiv_alias_v2
where row_end_dt = '9999-12-31' and
indiv_sorce_syst_cd = 'ORG') ee
on clm.c_ams_clm = ee.sorce_upc_indiv_id
inner join(select sorce_claim_id
,max(pmnt_rlse_dt) as mx_dt
,current_date - pmnt_rlse_dt as "Days Since Paid"
from ltc_p.claim_pmnt pp
having max(pmnt_rlse_dt) is not null) as d
on clm.i_sys_clm = d.sorce_claim_id
where clm.c_sta_clm = 'AC'
order by 1,2