• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 328
  • Last Modified:

empty ' ' if 0

Hello,

How can I return b as ' ' if the value is 0?

SELECT MyText, b=(SELECT count(*) FROM ATable)
from MyTable
0
johnkainn
Asked:
johnkainn
  • 2
1 Solution
 
gplanaCommented:
try this:

SELECT MyText, b=(SELECT CASE WHEN count(*)=0 THEN '' ELSE Count(*) END FROM ATable)
0
 
Vijaya Reddy Pinnapa ReddyCommented:
SELECT MyText, b=(SELECT CASE WHEN count(*)=0 THEN '' ELSE Count(*) END)
FROM MyTable
0
 
Vijaya Reddy Pinnapa ReddyCommented:
SELECT MyText, b=(SELECT CASE WHEN count(*)=0 THEN '' ELSE Count(*) END from ATable)
FROM MyTable
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now