Query Problem?? | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Query Problem??

Hi I am having trouble trying to figure out this sql query I need to display the opponents for a soccer team and display whether or not the team was at home or not at the moment I can display the two teams involved in the match and the stats I need but I don#%92t how to always get the other teams and display whether or not they were at home. This is my current query any help would be appreciated
Select homeClub.Name + ‘ v ‘ + awayClub.Name as Match, pz.DistanceCovered From Teams t
Join Person p on p.ID = t.PlayerID Join PZData pz on pz.TeamID = t.TeamID Join Match m on m.Id = t.MatchId
JOIN Squad homeSquad on m.SquadA = homeSquad.[ID]
JOIN Squad awaySquad on m.SquadB = awaySquad.[ID]
JOIN Club homeClub on homeSquad.ClubID = homeClub.[ID]
JOIN Club awayClub on awaySquad.ClubID = awayClub.[ID]
where t.ClubId in (select ClubID from Squad Where ID = 5)
and p.Id = 19
order by m.date asc

Please post your table structure, sample data and desired output, if you want a wuick and good solution. —
Frank Kalis
Microsoft SQL Server MVP
http://www.insidesql.de
Heute schon gebloggt?http://www.insidesql.de/blogs

]]>