PDA

View Full Version : Multiple counts from same table


Lionel
01-02-2006, 02:12 AM
I have that table where I set wins = 1 for winners.

user1 1
user2 0
user3 1

user1 1
user1 0
user2 1
user2 1
user3 0
user2 1


which means that
user1 has 2 wins
user2 has 3 wins
user3 has1 win

How can I get a count of total wins per user from the same query?

Logician
01-07-2006, 09:23 PM
use "count(*)" with "group by"

http://www.w3schools.com/sql/sql_groupby.asp

Lionel
01-07-2006, 09:47 PM
I did it with SUM(wins) AS userwins