I have the following table with two fields.
Table:
CREATE TABLE str_agg
(
cola varchar(50),
colb varchar(50)
);
Records:
insert into str_agg values('Alex','Student');
insert into str_agg values('Mak','Student');
insert into str_agg values('John','Teacher');
insert into str_agg values('Tony','Teacher');
I want to display the result in the comma separated format like as shown below:
Expected Result:
result
---------------------------------------------------------
Alex(Student),Mak(Student),John(Teacher),Tony(Teacher)
My try:
select string_agg(cola,'('||colb||'),') Result
from str_agg;
Getting result:
result
---------------------------------------------------------
Alex(Student),Mak(Teacher),John(Teacher),Tony
cola || '(' || colb || ')'and than pass it tostring_aggwith ',' delimiter ?