MySql Group_Concat

The result of GROUP_CONCAT is truncated to the maximum length that is given by the group_concat_max_len system variable, which has a default value of 1024.

This will cause  data-destroying bugs in production. For this reason you should probably not use GROUP_CONCAT . At least you must set the value of group_concat_max_len to an insanely high value on every database server your application runs on.

Like MAX or COUNT, GROUP_CONCAT is a MySQL aggregation function you can use whenever your query contains a GROUP BY. You can use it to retrieve a comma-separated list of all values in a given column within each group.

select  client
,Sum(Amount) as Amount_Total
,GROUP_CONCAT(Amount) as Amount_Detail
,GROUP_CONCAT(InvoiceNum) as Invoices
from mytable
 group by Client

Deixe uma resposta

O seu endereço de email não será publicado. Campos obrigatórios marcados com *