With played as
(
select tour_id ptour, match_id pmatch, team_id player, goals scored
from match_details
),
Versus as
(
Select tour_id vtour, match_id vmatch, team_id vplayer, goals conceded
From match_details
)
Select player, sum(scored) scored, sum(conceded) conceded, sum(scored - conceded) tot_diff
From played, versus
Where ptour = vtour
and pmatch = vmatch
And player <> vplayer
Group by player;