Hi When i went for an interview they asked me this question.
Create table course(Name CHAR(10));
insert into course values ('Java');
insert into course values ('Oracle');
insert into course values ('Python');
insert into course values ('C');
insert into course values ('C++');
o/p:
Java Oracle python c c++
Thanks in advance, Sandhya.
I presume that
NAMEcolumn's datatype should have beenVARCHAR2, notCHAR.Anyway, another option (similar to Tejash's
LISTAGG) which usesXMLAGGand is safer if the result is larger than 4000 characters.Or, as you tagged the question with PL/SQL tag, then an anonymous PL/SQL block might look like this:
Or - similarly - a function:
Or, a procedure with an
OUTparameter:As you can see, quite a few options; use the one that most suits your needs.