select a.A_id, concat(A_fname, ' ', A_Lname) as nm
, if(B_Date=d1 and B_round=1, cn, 0) as d1_1, if(B_Date=d1 and B_round=1, C_name, '') as cn_1_1
, if(B_Date=d1 and B_round=2, cn, 0) as d1_2, if(B_Date=d1 and B_round=2, C_name, '') as cn_1_2
, if(B_Date=d1 and B_round=3, cn, 0) as d1_3, if(B_Date=d1 and B_round=3, C_name, '') as cn_1_3
, if(B_Date=d2 and B_round=1, cn, 0) as d2_1, if(B_Date=d2 and B_round=1, C_name, '') as cn_2_1
, if(B_Date=d2 and B_round=2, cn, 0) as d2_2, if(B_Date=d2 and B_round=2, C_name, '') as cn_2_2
, if(B_Date=d2 and B_round=3, cn, 0) as d2_3, if(B_Date=d2 and B_round=3, C_name, '') as cn_2_3
from ( select *,'3/16/2018' as d1,'3/17/2018' as d2 from db_A) as a
left join (
select a.A_id, B_date, B_round, C_name, count(*) as cn
from db_ADD a
left join db_B b using B_id
left join db_C c using C_id
group by a.A_id, a.B_id, a.C_id
) as tc using A_id