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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.