The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!
SELECT
a.custid
, a.advisor
, a.account
, COUNT(DISTINCT a.advisor)
FROM customer_cars b
INNER JOIN Customer_Advisors a ON a.custid = TO_NUMBER(REGEXP_REPLACE(b.custid, '[^0-9]'))
WHERE b.car = 'BMW'
GROUP BY
a.custid
, a.advisor
, a.account
HAVING COUNT(DISTINCT a.advisor) > 1
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
From novice to tech pro — start learning today.
Open in new window
The pity is that LISTAGG() doesn't have a "distinct" option, hence the need for the derived table (A) that uses select distinct.details:
Open in new window