您好,我需要选择一个仅包含不同值的 listagg 列。不幸的是,我使用的是 oracle 18.c,它不支持直接不同的选项,所以我可能必须使用嵌套选择(不确定?)我有以下 SQL 查询,我需要列出“adrml.email”列不同的价值观。
select distinct
c.trader_transact
, t.trader_descr
, d.third
, d.f_name
, d.def_phone
, d.def_mail
, d.f_city
, d.country_descr
, d.f_street
, con.first_name
, con.last_name
, adrph.formated_phone_nr
, link.adr
, link.contact
,adrdet.dt
,adrdet.street Contact_Street
,adrdet.post_code
,adrdet.city
,adrdet.country
,adrml.email
,LISTAGG(
adrml.email,
' / '
) WITHIN GROUP(
ORDER BY
d.third
)
from thr_v_third d
join tra_contract c on d.third = c.customer or d.third = c.supplier
join tra_trader t on t.trader = c.trader_transact
join thr_v_adr_lnk_contact link on link.third = d.third --and link.type = 1 and link.default_contact = 1
join adr_contact con on con.adr = link.adr and con.contact = link.contact
join adr_address_det adrdet on adrdet.adr = link.adr and adrdet.last = 1
left join adr_mail adrml on link.adr = adrml.adr and con.contact = adrml.contact and adrml.deflt = 1
left join adr_v_phones adrph on adrph.adr = link.adr and adrph.contact = link.contact and adrph.deflt = 1 and adrph.type = 1
where t.trader = 32
group by
c.trader_transact
, t.trader_descr
,d.third
, d.f_name
, d.def_phone
, d.def_mail
, d.f_city
, d.country_descr
, d.f_street
, link.adr
, link.contact
, con.first_name
, con.last_name
,adrdet.dt
,adrdet.street
,adrdet.post_code
,adrdet.city
,adrdet.country
,adrml.email
, adrph.formated_phone_nr
order by d.third
到目前为止,我在 listagg 列中收到重复的电子邮件。我怎样才能清除这个?