Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Substituting a zero value

Status
Not open for further replies.

Nsan

MIS
Apr 30, 2003
13
0
0
I run the following:

select custname, count(custid) as CUST

Produces the following:

Brandon 0
Greg 0
Sam 5
Chris 0
Steve 2
Jordan 0

How can I substitute the zero values for a blank space?

Thx
 
Try this . .
Code:
select custname, case count(custid) when 0 then '' else count(custid) end as CUST . .


Regards,


"There are no secrets to success. It is the result of preparation, hard work, and learning from failure." -- Colin Powell
 
FYI count() returns integer, '' is a string.

------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
[banghead]
 
Thanks for the suggestion, but no change


Same results


Brandon 0
Greg 0
Sam 5
Chris 0
Steve 2
Jordan 0
 
Like Vongrunt suggested, you need to treat either case to return a string.

Code:
select custname, 
       case count(custid) 
          when 0 
          then '' 
          else Convrt(VarChar(20), count(custid))
          end as CUST

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top