For getting important data date wise SELECT IFNULL(t1.date,t2.date) as date, IFNULL(SentMessages,0) as sentMessage , IFNULL(ReceivedMessages,0) as receivedMessage, IFNULL(BoughtNumbers,0) as BoughtNumbers, IFNULL(ReleasedNumbers,0) as ReleasedNumbers FROM (SELECT DATE(uh.createdDate) as date, SUM(case when STRCMP(`direction`, 'outbound-api') = 0 then 1 else 0 end) as SentMessages, SUM(case when STRCMP(`direction`, 'Inbound') = 0 then 1 else 0 end) as ReceivedMessages FROM `user_history` uh GROUP BY date) t1 LEFT JOIN (SELECT DATE(pn.createdDate) as date, SUM(case when pn.`status` = 1 then 1 else 0 end) as BoughtNumbers, SUM(case when pn.`status` = 9 then 1 else 0 end) as ReleasedNumbers FROM phone_number pn GROUP BY date) t2 ON t1.date=t2.date UNION SELECT IFNULL(t3.date,t4.date) as date, IFNULL(SentMessages,0) as sentMessage , IFNULL(ReceivedMessages,0) as receivedMessage, IFNULL(BoughtNumbers,0) as BoughtNumbers, IFNULL(ReleasedNumbers,0) as ReleasedNumbers FROM (SELECT DATE(uh.createdDate) as date, SUM(case when STRCMP(`direction`, 'outbound-api') = 0 then 1 else 0 end) as SentMessages, SUM(case when STRCMP(`direction`, 'Inbound') = 0 then 1 else 0 end) as ReceivedMessages FROM `user_history` uh GROUP BY date) t3 RIGHT JOIN (SELECT DATE(pn.createdDate) as date, SUM(case when pn.`status` = 1 then 1 else 0 end) as BoughtNumbers, SUM(case when pn.`status` = 9 then 1 else 0 end) as ReleasedNumbers FROM phone_number pn GROUP BY date) t4 ON t3.date=t4.date ORDER BY `date` DESC