MySQL的:
SELECT
group_concat(cu1.cu_inflow_type),count(cu1.cu_inflow_type)
FROM cs_test cu1
LEFT JOIN cs_test cu2
ON cu2.seq=cu1.seq
GROUP BY cu1.cu_inflow_type
结果:
======================================================================
group_concat(cu1.cu_inflow_type) | count(cu1.cu_inflow_type)
----------------------------------------------------------------------
001,001,001,001,001,001,001,00.. | 27
002,002 | 2
003,003 | 2
004,004,004 | 3
005 | 1
006 | 1
----------------------------------------------------------------------
查询运行,但这不是我想要的结果。我希望它看起来像:
======================================================================
group_concat(cu1.cu_inflow_type) | count(cu1.cu_inflow_type)
----------------------------------------------------------------------
001,001,001,001,001,001,001,00.. | 27
002,002,003,003 | 4 <-- add!
004,004,004 | 3
005,006 | 2 <-- add!
----------------------------------------------------------------------
'002,002'+'003,003'= 002,002,003,003
我不明白如何在MySQL中使用group_concat()
来获得所需的结果。有人能帮助我吗?
答案 0 :(得分:0)
您可以使用group by group
中的其他字段