I am trying to use the LISTAGG function in Oracle. I would like to get only the distinct values for that column. Is there a way in which I can get only the distinct values without creating a function or a procedure?
col1 col2 Created_by
1 2 Smith
1 2 John
1 3 Ajay
1 4 Ram
1 5 Jack
I need to select col1 and the LISTAGG of col2 (column 3 is not considered). When I do that, I get something like this as the result of LISTAGG: [2,2,3,4,5]
I need to remove the duplicate '2' here; I need only the distinct values of col2 against col1.