I have a table with six columns as following
Home_Team | Home_Score | Away_Score | Away_Team | Home_Result | Away_Result
I want to select the output of Home_Team record of win, loos & tie matches.
I used the following query however instead of counting individual totals it is showing count if all matches in each category.
select a.Home_Team,
if(a.Home_Result = 'Win', count(a.Home_Result), 0) as Win,
if(b.Home_Result = 'Loss', count(b.Home_Result), 0) as Loss
from nsfa.result_main_bck as a
join nsfa.result_main_bck as b
on a.Home_Team = b.Home_Team
where a.Home_Result = 'Win' and b.Home_Result = 'Loss'
Group by 1
What could be wrong in this code
I am using MySql by the way.
Regards