Use LINQ to concatenate multiple rows into single row (CSV property)

That’s the GroupBy operator. Are you using LINQ to Objects? Here’s an example: using System; using System.Collections.Generic; using System.Linq; public class Test { static void Main() { var users = new[] { new { User=”Bob”, Hobby=”Football” }, new { User=”Bob”, Hobby=”Golf” }, new { User=”Bob”, Hobby=”Tennis” }, new { User=”Sue”, Hobby=”Sleeping” }, new { User=”Sue”, … Read more

Show a one to many relationship as 2 columns – 1 unique row (ID & comma separated list)

I believe that the answer you need is a user-defined aggregate, similar to this one: CREATE FUNCTION gc_init(dummy VARCHAR(255)) RETURNING LVARCHAR; RETURN ”; END FUNCTION; CREATE FUNCTION gc_iter(result LVARCHAR, value VARCHAR(255)) RETURNING LVARCHAR; IF result=”” THEN RETURN TRIM(value); ELSE RETURN result || ‘,’ || TRIM(value); END IF; END FUNCTION; CREATE FUNCTION gc_comb(partial1 LVARCHAR, partial2 LVARCHAR) … Read more

Concatenate and group multiple rows in Oracle [duplicate]

Consider using LISTAGG function in case you’re on 11g: select grp, listagg(name,’,’) within group( order by name ) from name_table group by grp sqlFiddle upd: In case you’re not, consider using analytics: select grp, ltrim(max(sys_connect_by_path (name, ‘,’ )), ‘,’) scbp from (select name, grp, row_number() over (partition by grp order by name) rn from tab … Read more

GROUP_CONCAT with limit

One somewhat hacky way to do it is to post-process the result of GROUP_CONCAT: substring_index(group_concat(s.title SEPARATOR ‘,’), ‘,’, 3) as skills Of course this assumes that your skill names don’t contain commas and that their amount is reasonably small. fiddle A feature request for GROUP_CONCAT to support an explicit LIMIT clause is unfortunately still not … Read more