I tried many way but didn\'t get expected result. How can I get expected result.
You can download the dbtable structure from here :-
SELECT
IF(
According to your database schema, if you just want your expected result, please try following sql;)
select
case source_id when 1 then 'online' when 2 then 'visit' when 3 then 'phone' end as `Type`,
sum(if(month(date_created) = 5, total_price, 0)) as `May`,
sum(if(month(date_created) = 6, total_price, 0)) as `June`
from `orders`
where date_created between (curdate() - interval 1 month) and curdate()
group by source_id
SQLFiddle DEMO HERE.