How do I eliminate the duplicate records in the one cell?
select distinct pat_enc.pat_id
,LISTAGG(ZC_SPECIALTY.name, ',') WITHIN GROUP (ORDER BY ZC_SPECIALTY.name) specialty
from pat_enc
id visit_type
000027424 Gastroenterology,Gastroenterology
000038355 Cardiology,Cardiology,Cardiology,Cardiology,Cardiology