Search code examples
sqlgroup-bygroup-concat

Multiple group_concat ordering one of them wrong order of the others


i have 3 columns a, b and c.
I need as output:

  • a
  • b as group_concat
  • c as group_concat (order ASC)

I can do a order by inside of the group_concat but the issue is that the order of b is not correct order for c them.

I never had that situation so i dont now how i can solve that.


Solution

  • Is this what you are looking for:

    select a, group_concat(b order by c), group_concat(c order by c)
    from t
    group by a;