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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

counting nulls 1

Status
Not open for further replies.

angela4eva

Programmer
Apr 29, 2005
46
US
i have stored orocedure
select amount, desc,count(desc) as cnt from emp
group by desc
but some of the values in desc is null..
so i guess its not getting counted
i am getting like
amount desc cnt
1000 aaj 22
500 0
HOW CAN I COUNT THE NUMBER OF RECORDS WITH NULL THAT made up the 500 amount and also put the vount in the count column ..any help apprecited
 
use coalesce or isnull

“I sense many useless updates in you... Useless updates lead to fragmentation... Fragmentation leads to downtime...Downtime leads to suffering..Fragmentation is the path to the darkside.. DBCC INDEXDEFRAG and DBCC DBREINDEX are the force...May the force be with you" --
 
COUNT(*) also counts NULLs.
COUNT(somecolumn) does NOT count NULLs.
COUNT(*)-COUNT(somecolumn) will tell ya how many somecolumn values are NULLs.

Pick one :)

------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
[banghead]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top