Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Count question

Author  Topic 

neutcomp
Posting Yak Master

111 Posts

Posted - 2003-06-30 : 16:09:41
Have a tbl_games


id speler_one speler_two
1 10 12
2 12 10
3 10 13
4 13 12
5 13 10
6 15 10
7 15 13



Now I want to count how many games speler_one=10 has played.


SELECT speler_one, speler_two, Count(speler_one) AS AantalGames
FROM tbl_game
GROUP BY speler_one, speler_two
HAVING speler_one=10;



I get as result 2. And NOT 5, because he only counts speler_one.
How can I fix this?

Thanxx
Bjorn

P.s. the dartgame keeps comming back ;-)



Edited by - neutcomp on 06/30/2003 16:13:25

nr
SQLTeam MVY

12543 Posts

Posted - 2003-06-30 : 16:18:08
SELECT speler = 10, Count(*) AS AantalGames
FROM tbl_game
where speler_one=10 or speler_two=10


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

neutcomp
Posting Yak Master

111 Posts

Posted - 2003-07-01 : 05:47:29
Thanxx it worked

Cya
Bjorn

Go to Top of Page
   

- Advertisement -