Home » SQL & PL/SQL » SQL & PL/SQL » return comma seperated values
return comma seperated values [message #281902] Mon, 19 November 2007 22:15 Go to next message
miroconnect@yahoo.com
Messages: 202
Registered: April 2006
Senior Member
Can a sql query return comma, seperated values rather than multiple rows ?
I mean my query return 3 rows
select employee_id from employees
employee id
1
2
3
is there any way to return 1,2,3 ?

Re: return comma seperated values [message #281903 is a reply to message #281902] Mon, 19 November 2007 22:21 Go to previous messageGo to next message
rajavu1
Messages: 1574
Registered: May 2005
Location: Bangalore , India
Senior Member


Try google for "Pivot queries" or even in the forum.

Have a nice search !!!!

Thumbs Up
Rajuvan.
Re: return comma seperated values [message #281920 is a reply to message #281903] Tue, 20 November 2007 00:48 Go to previous messageGo to next message
Maaher
Messages: 7062
Registered: December 2001
Senior Member
This is a true classic. You will find tons of examples. I think of the MODEL clause, stragg/concat_all, sys_connect_by_path, ...

MHE
Re: return comma seperated values [message #281921 is a reply to message #281902] Tue, 20 November 2007 00:52 Go to previous messageGo to next message
Michel Cadot
Messages: 64152
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:

is there any way to return 1,2,3 ?

Yes, many.

Regards
Michel
Re: return comma seperated values [message #282004 is a reply to message #281902] Tue, 20 November 2007 06:04 Go to previous messageGo to next message
ebrian
Messages: 2794
Registered: April 2006
Senior Member
select wmsys.wm_concat(employee_id) from employees;
Re: return comma seperated values [message #282010 is a reply to message #281902] Tue, 20 November 2007 06:44 Go to previous messageGo to next message
miroconnect@yahoo.com
Messages: 202
Registered: April 2006
Senior Member
can I know more about wmsys.wm_concat ?.
Re: return comma seperated values [message #282017 is a reply to message #282010] Tue, 20 November 2007 07:30 Go to previous messageGo to next message
Michel Cadot
Messages: 64152
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Not documented.

Regards
Michel
Re: return comma seperated values [message #282020 is a reply to message #281902] Tue, 20 November 2007 07:32 Go to previous messageGo to next message
miroconnect@yahoo.com
Messages: 202
Registered: April 2006
Senior Member
are there any drawbacks of using wmsys.wm_concat ? any disadvantages is it safe to use ?
Re: return comma seperated values [message #282021 is a reply to message #282020] Tue, 20 November 2007 07:34 Go to previous message
Michel Cadot
Messages: 64152
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Internal stuff no documented, use it at your own risk.
Otherwise search for the other provided solutions, all documented, tested and safe.

Regards
Michel
Previous Topic: ORA-00937: not a single-group group function.
Next Topic: how to written some default value from sql query
Goto Forum:
  


Current Time: Sat Dec 10 20:49:45 CST 2016

Total time taken to generate the page: 0.09371 seconds