Making Count(*) return zero
From: Guto <gutomore_at_gmail.com>
Date: Wed, 9 Dec 2009 12:01:24 -0800 (PST)
Message-ID: <45ecb476-76e7-4c56-940c-8298588d1617_at_j19g2000yqk.googlegroups.com>
Hi There!
4 0
Date: Wed, 9 Dec 2009 12:01:24 -0800 (PST)
Message-ID: <45ecb476-76e7-4c56-940c-8298588d1617_at_j19g2000yqk.googlegroups.com>
Hi There!
is there a way to make the count(*) return zero . because the default behavoir is that it will skip this value if there is no records so a simple query like this
select userid,count(*) as count from users where userid in (select val
from sometable)
group by userid
if userid 1 has no records . it wont be returned in the query
instead i want it to show zero so
userid count
1 0
2 3
3 1
4 0
Any hints?
Thanks!
Guto.
Received on Wed Dec 09 2009 - 21:01:24 CET