problem with NULL

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
karmic
Forum Newbie
Posts: 2
Joined: Fri May 24, 2002 12:30 pm

problem with NULL

Post 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
User avatar
NetDragonX
Forum Newbie
Posts: 15
Joined: Sat May 25, 2002 3:00 pm
Location: Southern California

Post by NetDragonX »

umm... you spelt 'group' wrong maybe?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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
User avatar
mikeq
Forum Regular
Posts: 512
Joined: Fri May 03, 2002 3:33 am
Location: Edinburgh, Scotland

Post by mikeq »

try


group by isnull(STATUS,'ACTIVE')

Mike
karmic
Forum Newbie
Posts: 2
Joined: Fri May 24, 2002 12:30 pm

Post by karmic »

mikeq:
That worked!!! :D
Now that I think about it, it makes sence.
Thanx!!!
Post Reply