Concatenating text data in a column using SQL

251 Views Asked by At

Does anyone know how to concatenate all the values of a column in a query using SQL only? I know that there are ways using database specific tools such as pivot, but I don't think I have access to something like that in infomaker.

I am using infomaker to produce labels for sample bottles. The bottles can be analysed for more than one thing. If I join the bottle and analysis tables I get several rows per bottle which results in multiple labels, so I was hoping to concatenate all the values for the analysis using SQL and then use a computed value based on this to add something useful to the label. I can only use 1 transaction based on a select query to do this.

Adding additional tables or columns to the database would be highly discouraged.

1

There are 1 best solutions below

0
On

In some oracle version you can use wm_concat

SELECT field1, wm_concat(field2) FROM YourTable 
GROUP BY field2;

otherwise you can use listagg