I have a table with call records. Each call has a 'state' CALLSTART and CALLEND, and each call has a unique 'callid'. Also for each record there is a unique autoincrement 'id'. Each row has a MySQL TIMESTAMP field.
In a previous question I asked for a way to calculate the total of seconds of phone calls. This came to this SQL:
SELECT SUM(TIME_TO_SEC(differences)) FROM ( SELECT SEC_TO_TIME(TIMESTAMPDIFF(SECOND,MIN(timestamp),MAX(timestamp)))as differences FROM table GROUP BY callid )x Now I would like to know how to do this, only for callid's that also have a row with the state CONNECTED.
Screenshot of table: https://i.sstatic.net/nEnUJ.jpg