poe Posted November 15, 2006 Share Posted November 15, 2006 team opp wlt gf ga-----------------------------------------tor mtl w 5 1 tor phi w 4 1 tor atl w 4 2 tor ott l 2 6 tor nyr so 4 5 tor col l 1 4 tor cgy w 5 4 tor fla w 2 1 tor mtl so 2 3 tor ott l 1 4 the result i want is:team games wins loss tie ttlgf ttlga - ...note (so=tie) tor 10 5 3 2 30 31the query i have is :query = SELECT team, count(team), count(wlt), sum(gf), sum(ga) FROM games WHERE team='tor'basically:get the teamgames = count the rowswins = count 'w'loss = count 'l'tie = count 'so'ttlgf & ttlga = sum()thanks Quote Link to comment Share on other sites More sharing options...
shoz Posted November 15, 2006 Share Posted November 15, 2006 [code]SELECTteam, COUNT(*) AS games,SUM(wlt = 'w') AS wins, SUM(wlt = 'l') AS loss, SUM(wlt = 'so') AS tie,SUM(gf) AS ttlgf, SUM(ga) AS ttlgaFROMgamesWHEREteam = 'tor'[/code] Quote Link to comment Share on other sites More sharing options...
fenway Posted November 15, 2006 Share Posted November 15, 2006 Interesting... I thought you had to use the SUMIF() function for that. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.