使用mysql查询或Proc,我试图给每个聊天组一个唯一的ID。 用户可以使用company_id进行多次聊天
Chat(id,type,company_id)
Type=0 Chat Stated by User
Type=1 Chat Started by Agent
Type=2 Chat End By Agent
Sample Data
1,0,21 : 1st Chat started by user
2,0,21
3,1,21
4,0,341 :Chat Started by user
5,2,21 : 1st Chat End by Agent
6,1,341
7,2,341
8,0,21 :Chat stated by user
9,1,21
10,2,21
预期结果
1,1,0,21 : 1st Chat started by user
1,2,0,21
1,3,1,21
2,4,0,341 :Chat Started by user
1,5,2,21 : 1st Chat End by Agent
2,6,1,341
2,7,2,341
3,8,0,21 :Chat stated by user
3,9,1,21
3,10,2,21