0

I have the following problem with Informix

Fail:

client  username
ABC     usr1
ABC     usr2
CDF     usr3
CDF     usr4

Correct:

client  username
ABC     usr1, usr2
CDF     usr3, usr4

What is the query correct to obtain the correct result?

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
  • Post the query you tried as part of the answer – Joey Harwood Jan 10 '18 at 18:28
  • Check [**SO - 715350**](https://stackoverflow.com/questions/715350/show-a-one-to-many-relationship-as-2-columns-1-unique-row-id-comma-separate). Informix does not have an aggregate similar to `GROUP_CONCAT`but you can create your own. – Luís Marques Jan 10 '18 at 22:28
  • Note that the GROUP_CONCAT operator doesn't normally include a space after the comma separator. It would be possible to define it so that it does. – Jonathan Leffler Jan 11 '18 at 06:02

1 Answers1

0
SELECT client, GROUP_CONCAT(username)
  FROM someTable
 GROUP BY client;

does that works ?

Leo
  • 519
  • 2
  • 10