我的sql客户呼叫详细信息表中有一个数据,其中一个号码多次,有些第一次没有连接或下垂,但第二次连接,所以我只想获取从未连接过的数据
例: 这实际上是数据
Customer_Number Status
123 dropped
456 connected
789 dropped
123 connected
456 connected
789 dropped
789 not connected
我想得到这样的数据:
Customer_Number Status
789 dropped
它应该只显示那些从未连接的Customer_number。该查询连接每个客户编号的所有状态,并仅显示connection_status从未包含"已连接"的号码
select Customer_Number, group_concat(DISTINCT status) as connection_status
from customers
GROUP BY Customer_Number
HAVING connection_status = 'dropped,not connected' OR connection_status='not connected,dropped'