Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Count Nulls ?

Status
Not open for further replies.

besto1a

Programmer
Aug 20, 2006
41
GB
I have a basic Query:

SELECT CurrentStatus, COUNT(CurrentStatus) AS [Count of Status]
FROM dbo.tbl_EWTCases
GROUP BY CurrentStatus

THis works fine but will not produce a total for anything that is showing as Status null, how do i get this to count nulls ?

THanks
 
Code:
SELECT     CurrentStatus, COUNT([!]*[/!]) AS [Count of Status]
FROM         dbo.tbl_EWTCases
GROUP BY CurrentStatus

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
This should include nulls

SELECT CurrentStatus,
COUNT(ISNULL(CurrentStatus,0)) AS [Count of Status]
FROM dbo.tbl_EWTCases
GROUP BY CurrentStatus

- Paul [batman]
- If at first you don't succeed, find out if the loser gets anything.
 
But George and Denis are correct.
COUNT(*) gets everything.


- Paul [batman]
- If at first you don't succeed, find out if the loser gets anything.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top