数据如下:
CallID | callin | callout
456 | 16267777 | *123
456 | *123 |19095351
789 | 1323789 | *123
789 | *123 |180515978
(* 123是系统分机号码)
表名:call_history
现在我想将数据重新组合成:
CallID callin callout
456 16267777 19095351
789 1323789 180515978
我该怎么办?通过使用Selfjoin? GROUP?
谢谢!
答案 0 :(得分:0)
您可以使用内部联接
select a.callID, a.callin, b.callout
from call_history as a
inner join call_history as b on a.callID = b.callID
where a.callin !='*123'
and b.callout !='*123'