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)
 GROUP BY query

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-04-11 : 09:26:05
Matt writes "Hello, i'm using this code to count the number of appearances a player has made in a season

SELECT COUNT (PlayerFixture.FixtureID) FROM PlayerFixture WHERE PlayerFixture.PlayerID = '::PlayerID::' GROUP BY Season

by querying table (PlayerFixture) but if a player doesn't play in a particular season how can i get it to return a value of "0" or "-"?
At the moment it just ignores the season and then i have a line missing.
Any ideas?"

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-04-11 : 10:01:50
Is this inside a stored Procedure?
Or u just pass the query to the SQL server and get the results to a Recordset?

Srinika
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2006-04-11 : 11:05:43
You could try:

SELECT COALESCE((
SELECT COUNT (PlayerFixture.FixtureID) FROM PlayerFixture WHERE PlayerFixture.PlayerID = '::PlayerID::' GROUP BY Season
), 0)
Go to Top of Page
   

- Advertisement -