How to concat all column values from differenct rows returned from a sql query into one value? This is an example:
a query returns:
FOO
------
RES1
RES2
Edit: Since version 8.4.0 CUBRID provides 90% compatibility with MySQL. Thus, it supports GROUP_CONCAT which has similar syntax as in MySQL:
CREATE TABLE t(i int);
INSERT INTO t VALUES (4),(2),(3),(6),(1),(5);
SELECT GROUP_CONCAT(i*2+1 ORDER BY 1 SEPARATOR '') FROM t;
group_concat(i*2+1 order by 1 separator '')
======================
'35791113'
Quite powerful, isn't it? And below is an alternative solution supported natively in CUBRID.
SELECT MAX(SYS_CONNECT_BY_PATH(s_name, '')) AS conc_s_name
FROM (
SELECT ROWNUM AS r, s_name FROM code
) AS res
START WITH r = 1
CONNECT BY PRIOR r = r - 1;
It's so interesting that this way of concatenating different row column values in CUBRID is almost identical to Oracle's way as provided by @devio. In CUBRID it looks a little bit easier though.