A B C Result(A) |Result(B)
1 All 9 1 | All~9-8
1 All 8 2 | Been~6
2 Been 6 3 | Hai~5
3 Hai 5
2 Been 6
A,B和C是列名B和C应根据列a连接,并应存储在两列结果(A)和结果(B)
答案 0 :(得分:0)
结果与样本中的结果不同,但类似的结果可能基于CONCAT_WS
select a, b, concat(b,'~', concat_ws('-',c))
from my_table
group by A,B
答案 1 :(得分:0)
您也可以使用group_concat
来实现此目标
SELECT A AS Result_A, CONCAT(B,'~', GROUP_CONCAT(C SEPARATOR '~')) AS Result_B FROM table GROUP BY B