Jump to content

combining sum() and counts in 1 query


poe

Recommended Posts

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 31



the query i have is :

query = SELECT team, count(team), count(wlt), sum(gf), sum(ga) FROM games WHERE team='tor'

basically:
get the team
games = count the rows
wins = count 'w'
loss = count 'l'
tie = count 'so'
ttlgf & ttlga = sum()

thanks
Link to comment
https://forums.phpfreaks.com/topic/27313-combining-sum-and-counts-in-1-query/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.