SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 null values
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

kemi2299
Starting Member

United Kingdom
41 Posts

Posted - 05/13/2008 :  07:35:04  Show Profile  Reply with Quote
hi,

just a quick question, can null values be count?

SwePeso
Patron Saint of Lost Yaks

Sweden
30265 Posts

Posted - 05/13/2008 :  07:36:55  Show Profile  Visit SwePeso's Homepage  Reply with Quote
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

United Kingdom
41 Posts

Posted - 05/13/2008 :  07:53:47  Show Profile  Reply with Quote
hi,

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

soorajtnpki
Posting Yak Master

India
231 Posts

Posted - 05/13/2008 :  07:58:21  Show Profile  Reply with Quote
HI
JUST USE
SELECT * FROM TABLE_NAME WHERE FIELD_NAME IS NOT NULL


OK tanx...

Edited by - soorajtnpki on 05/13/2008 07:59:31
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 05/13/2008 :  11:15:25  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000