Page 1 of 1

problem with NULL

Posted: Fri May 24, 2002 12:30 pm
by karmic
I have a table with the following values:
CUST_ID STATUS
1000000 NULL
1000001 ACTIVE
1000002 DEACT

where I do
select count(*),isnull(STATUS,'ACTIVE') as STATUS
from CUSTOMER_TABLE
grop BY STATUS

why do I get
1 ACTIVE
1 ACTIVE
1 DEACT

instead of
2 ACTIVE
1 DEACT

Any help appreaciated, BTW,I 'm using SQL server 7.0

Posted: Sun May 26, 2002 6:54 pm
by NetDragonX
umm... you spelt 'group' wrong maybe?

Posted: Sun May 26, 2002 7:44 pm
by volka
he would get a systax error.
I tried

Code: Select all

Select count(*), IFNULL(STATUS, 'ACTIVE') as nStatus From CUSTOMER_TABLE GROUP BY nStatus
with mysql and it worked 8O

Posted: Mon May 27, 2002 2:43 am
by mikeq
try


group by isnull(STATUS,'ACTIVE')

Mike

Posted: Tue May 28, 2002 11:57 am
by karmic
mikeq:
That worked!!! :D
Now that I think about it, it makes sence.
Thanx!!!