【问题标题】:Multiple group_concat ordering one of them wrong order of the others多个 group_concat 排序其中一个错误的其他顺序
【发布时间】:2020-09-19 04:56:11
【问题描述】:

我有 3 列 a、b 和 c。
我需要作为输出:

  • 一个
  • b 作为 group_concat
  • c 作为 group_concat(顺序 ASC)

我可以在 group_concat 内部进行排序,但问题是 b 的顺序对 c 来说不是正确的顺序。

我从来没有遇到过这种情况,所以我现在不知道如何解决。

【问题讨论】:

  • 请提供样本数据和期望的结果。
  • 请提供样本数据和期望的结果。

标签: sql group-by group-concat


【解决方案1】:

这是你要找的东西吗:

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

【讨论】:

  • 是的,谢谢。我想这很容易弄清楚:P
猜你喜欢
  • 2018-09-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-09-24
  • 2017-01-07
  • 1970-01-01
  • 2021-05-29
  • 2012-06-01
相关资源
最近更新 更多