On 12/13/17, Valentin Davydov <sqlite-u...@soi.spb.ru> wrote:
> Given the following table:
>
> CREATE TABLE people(name,sex);
> INSERT INTO people VALUES("Alex","F");
> INSERT INTO people VALUES("Alex","M");
> INSERT INTO people VALUES("Jane","F");
> INSERT INTO people VALUES("John","M");
>
> How to construct a query which returns coalesced sex but individual names,
> such as "F: Alex, Jane. M: Alex, John."?

SELECT sex || ': ' || group_concat(name, ", ")  FROM people GROUP BY sex;

-- 
D. Richard Hipp
d...@sqlite.org
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to