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
 Transact-SQL (2000)
 null values

Author  Topic 

kemi2299
Starting Member

41 Posts

Posted - 2008-05-13 : 07:35:04
hi,

just a quick question, can null values be count?

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-05-13 : 07:36:55
Yes.

1) COUNT(*)
2) SUM(CASE WHEN Col1 IS NULL THEN 1 ELSE 0 END)



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

kemi2299
Starting Member

41 Posts

Posted - 2008-05-13 : 07:53:47
hi,

what if i want to exclude the null values
Go to Top of Page

soorajtnpki
Posting Yak Master

231 Posts

Posted - 2008-05-13 : 07:58:21
HI
JUST USE
SELECT * FROM TABLE_NAME WHERE FIELD_NAME IS NOT NULL


OK tanx...
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-05-13 : 11:15:25
quote:
Originally posted by kemi2299

hi,

what if i want to exclude the null values


if you want count of non null values:-
SUM(CASE WHEN Col1 IS NOT NULL THEN 1 ELSE 0 END)

or

COUNT(Col1)
Go to Top of Page
   

- Advertisement -