Use subqueries, but at a slower pace.
SELECTbaoming.id, Baoming.addtime as 'Registration Time', CONCAT (members.realname,members.username) as 'Customer Name', Sem.name as' channel source ', Case whenBmcs_fd_time is not NULL Then"Split order"ELSE"No Order"END as' Is it a single ', Case when(SELECT COUNT(ID) fromCome_go_phone_logsWHEREbaoming_id=Baoming.id andConnect_status= 1 andCall_mode= 2)> 0 ThenOnELSE"Not Connected"END as' is connected ', (SELECT COUNT(ID) fromCome_go_phone_logsWHEREbaoming_id=Baoming.id andCall_mode= 2) as 'Number of contacts', (SELECT MIN(Call_time) fromCome_go_phone_logsWHEREbaoming_id=Baoming.id andCall_mode= 2) as 'First Contact Time', (SELECT MIN(Call_time) fromCome_go_phone_logsWHEREbaoming_id=Baoming.id andCall_mode= 2 andCall_time>' First Contact time ') as '2nd Contact Time', (SELECT MIN(Call_time) fromCome_go_phone_logsWHEREbaoming_id=Baoming.id andCall_mode= 2 andCall_time>' 2nd contact time ') as '3rd Contact Time', (SELECT MIN(Call_time) fromCome_go_phone_logsWHEREbaoming_id=Baoming.id andCall_mode= 2 andCall_time>' 3rd contact time ') as '4th Contact Time' from' baomings ' asbaoming Left JOINCome_go_phone_logs asPhone onphone.baoming_id=baoming.id Left JOIN' Members ' as Members onPhone.seats_cs=Members . ' ID ' Left JOIN' Sem_sources ' asSem onSem.j_name=Baoming.bm_laiyuanWHEREBaoming.addtime>= '2017-07-01 00:00:00' andBaoming.is_fp= 1 andBaoming.zx_tuijian= 1 andBaoming.addtime<= '2017-07-11 23:59:59' andBaoming.idinch(SELECTBAOMING_ID,COUNT(ID) asC fromCome_go_phone_logsWHEREConnect_status= 1 andCall_mode= 2 ) GROUP byBaoming.id
SQL asks Max and Min, but second big, second small how to calculate?