select c1.caller_id_number , date_trunc('minute', c1.start_stamp) , row_number() over(partition by c1.caller_id_number order by c1.start_stamp) , c1.id , ( select count(*) from cdr c3 join cdr c4 on c3.bleg_uuid = c4.uuid where c4.start_stamp > c1.end_stamp and c4.billsec > 0 and c1.caller_id_number = c3.caller_id_number and c1.destination_number = c3.destination_number and c1.d_company_id = c3.d_company_id) from cdr c1 left outer join cdr c2 on c1.bleg_uuid = c2.uuid where c1.id > (select coalesce(max(cdr_id), 0) from kardio_2h_missed) and c1.d_company_id = (select id from companies where name = 'kardio') and (c2.billsec = 0 or c2.billsec is null) and c1.destination_number = '73852508950' and c1.id not in ( select id from kardio_2h_missed where send_timestamp >= now() - interval '1 week' ) and c1.start_stamp >= '2018 Feb 09'::date and c1.caller_id_number <> '73833732902' order by c1.start_stamp;