Don't know if this is the quickest way, but it works.Select Distinct a.MatchID, Case a.matches When 1 then b.ScoreA Else c.wonEnd ScoreA,Case a.matches When 1 then b.ScoreB Else c.LostEnd ScoreBFROM (Select MatchID, Count(*) MatchesFrom matchesGroup by MatchID) aLEFT JOIN matches bon a.MatchID = b.MatchIDLEFT JOIN(Select aa.MatchID, sum(aa.Won) Won, sum(aa.Lost) LostFROM (Select MatchID, Case When ScoreA > ScoreB then 1 else 0 End Won,Case When ScoreA < ScoreB then 1 else 0 End LostFrom matches) aaGROUP BY aa.MatchID) con a.MatchID = c.MatchID
JeremyEdited by - joldham on 04/07/2003 10:21:05