I am trying to create a concatenated string of values based on rows using Oracle LISTAGG. Here is the simplified code that still exhibits the issue I am trying to solve.

```
SELECT S_SUBJECT.UNIQRECNUM,                      
(SELECT LISTAGG(S_STUDY.U_PRIMARYRESEARCHCOHORT,',') WITHIN GROUP ( 
     ORDER BY U_PRIMARYRESEARCHCOHORT)
     FROM S_STUDY
     WHERE S_STUDY.S_STUDYID = S_PARTICIPANT.SSTUDYID) COHORTS

FROM S_SUBJECT
JOIN S_PARTICIPANT ON S_PARTICIPANT.SUBJECTID = S_SUBJECT.S_SUBJECTID
WHERE S_SUBJECT.UNIQRECNUM IN ('9','8','7','6','5','2');

These are the results of this query;
UNIQRECNUM | COHORTS
---------------------
    2      | Gastro
    5      | Metabolic
    6      | Cardio
    7      | Cardio
    8      | Gastro
    8      | Cardio
    9      | Gastro
    9      | Gastro
    9      | Gastro

What I am expecting to see from LISTAGG would be
UNIQRECNUM  | COHORTS
--------------------
    2       | Gastro
    5       | Metabolic
    6       | Cardio
    7       | Cardio
    8       | Cardio,Gastro
    8       | Cardio,Gastro
    9       | Gastro,Gastro,Gastro
    9       | Gastro,Gastro,Gastro
    9       | Gastro,Gastro,Gastro

```