Re: Making Count(*) return zero
Date: Wed, 09 Dec 2009 16:27:45 -0400
> 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?
Use a scalar subquery instead of just count(*) to calculate the [count] column.
-- is there something in it for them, like maybe bailouts, if they can panic us into doing something politically to cover them? November 19, 2007 - John S Bolton http://tinyurl.com/y9e4vxhReceived on Wed Dec 09 2009 - 21:27:45 CET