Hello World!
Im stuck with a SQL (SQL Server 2008) query. To sum up, we have a Table \"Teams\" which has two columns, teamID and name. Then we have another Table \"Matches\" that has, among other things, matchID,
localTeamID, visitorTeamID,localTeamGoals,visitorTeamGoals....etc etc. So the query requires the following: \"Return the name of the teams, indicating the number of matches played as local, and the number of matches played as visitor, as two different columns, in a single query, not allowed to use Cursors\".
The problem is, you need the team names, so when you do the join between Matches and Teams on, lets say, localTeamID = teamID, you only get the local matches...so in order to get the visitors aswell...you join again the same teamID with visitorTeamID....but there is my problem, for each local match, i get all the visitors matches...
How can I obtain the right result like
Team LocalMatches VisitorMatches
Real Madrid 4 5
Manchester 5 4
Note that \"sums\" or \"counts\" in the query may differ.
Thanks in advance, I hope anyone can help me here.
Hess