I have something like the following:
select count(mycolumn) from mytable where...
This works great. The problem is that sometimes, count(mycolumn) returns
null because mycolumn contains no values. In this case, I'd really rather
show the user a '0' rather than the word null.
Any suggestions on how to show the user a 0 (zero) when count returns a null
?
Thanks
--
RandyTry:
select isnull (count(mycolumn), 0)
from mytable where...
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Toronto, ON Canada
.
"randy1200" <randy1200@.newsgroups.nospam> wrote in message
news:E73AE804-52AF-4C79-ACEE-59385838204D@.microsoft.com...
I have something like the following:
select count(mycolumn) from mytable where...
This works great. The problem is that sometimes, count(mycolumn) returns
null because mycolumn contains no values. In this case, I'd really rather
show the user a '0' rather than the word null.
Any suggestions on how to show the user a 0 (zero) when count returns a
null?
Thanks
--
Randy|||Try,
select isnull(count(mycolumn), 0) from mytable where ...
go
AMB
"randy1200" wrote:
> I have something like the following:
> select count(mycolumn) from mytable where...
> This works great. The problem is that sometimes, count(mycolumn) returns
> null because mycolumn contains no values. In this case, I'd really rather
> show the user a '0' rather than the word null.
> Any suggestions on how to show the user a 0 (zero) when count returns a nu
ll?
> Thanks
> --
> Randy|||Exactly what I needed. Many thanks
--
Randy
"Tom Moreau" wrote:
> Try:
> select isnull (count(mycolumn), 0)
> from mytable where...
>
> --
> Tom
> ----
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> SQL Server MVP
> Toronto, ON Canada
> ..
> "randy1200" <randy1200@.newsgroups.nospam> wrote in message
> news:E73AE804-52AF-4C79-ACEE-59385838204D@.microsoft.com...
> I have something like the following:
> select count(mycolumn) from mytable where...
> This works great. The problem is that sometimes, count(mycolumn) returns
> null because mycolumn contains no values. In this case, I'd really rather
> show the user a '0' rather than the word null.
> Any suggestions on how to show the user a 0 (zero) when count returns a
> null?
> Thanks
> --
> Randy
>|||select count(mycolumn) from mytable where mycolumn is not null
?
"randy1200" <randy1200@.newsgroups.nospam> wrote in message
news:E73AE804-52AF-4C79-ACEE-59385838204D@.microsoft.com...
> I have something like the following:
> select count(mycolumn) from mytable where...
> This works great. The problem is that sometimes, count(mycolumn) returns
> null because mycolumn contains no values. In this case, I'd really rather
> show the user a '0' rather than the word null.
> Any suggestions on how to show the user a 0 (zero) when count returns a
null?
> Thanks
> --
> Randy
No comments:
Post a Comment