Solved

# How to get distinct value with comma separated in SQL?

Posted on 2009-07-07

Hi,

I have a query which will give the below output.

LINE_NUMBER MIN_1 MIN_2 MIN_3

1 200 300 400

2 200 300 400

3 200 300 400

4 100 200 400

5 300 600 700

6 100 200 400

In the above output, i have a line_number column will fetch the min_1, min_2, min_3 values. If you observe the output some of the line_number values contains the same row. For example line_number 1,2,3 are same and 4,6 are same and 5 is one row. I need the same in the output. I mean In my result i want to show the distinct of min_1, min_2, _min_3 values with comma spearated line_number like below. Can we achieve through SQL Queries or should we go for PL/SQL?

LINE_NUMBER MIN_1 MIN_2 MIN_3

1,2,3 200 300 400

4,6 100 200 400

5 300 600 700

Can anyone share with your thoughts?

Thanks