title: How to display text value 'X' if number is 0.00. SQL Server, Stored Procedures
body: <p>I want that value would be displayed in text 'X' when amount is equal 0.00</p>
  
  <p>Now code looks like this: </p>
  
  <p><code>SELECT SUM(Amount * 0.01) AS Amount</code></p>
  
  <p>And I tried:</p>
  
  <pre><code>select CASE
      WHEN SUM(Amount * 0.01) = 0.00 THEN 'X'
      ELSE SUM(Amount * 0.01)
      END AS Amount
  </code></pre>
  
  <p>Now output looks like this:</p>
  
  <pre><code>Amount
  0.00    
  21.04   
  8.34
  </code></pre>
  
  <p>I expect the output:</p>
  
  <pre><code>Amount
  X
  21.04
  8.34
  </code></pre>
  
  <h1>========================================</h1>
  
  <p>Added/edited info</p>
  
  <p>If i use like this (now SUM(Amount1 * 0.01) = 1)</p>
  
  <pre><code>SELECT * FROM
  (
  SELECT UserId
  ,CASE
      WHEN SUM(Amount1 * 0.01) = 1 THEN 'X'
      ELSE cast(SUM(Amount1 * 0.01) as varchar )
  END AS Amount1
  , CASE
      WHEN SUM(Amount2 * 0.01) = 1 THEN 'X'
      ELSE cast(SUM(Amount2 * 0.01) as varchar )
  END AS Amount2
  FROM Table1
  GROUP BY UserId
  ) as t1
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code>Amount1 Amount2
  X       15.01
  21.04   X
  8.30    9.70
  </code></pre>
  
  <p>and now i wanna display another table with sum amount</p>
  
  <pre><code>SELECT UserId, Amount1 + Amount2 as AllSum from t1
  </code></pre>
  
  <p>Expected result:</p>
  
  <pre><code>AllSum
  15.01
  21.04
  18.00
  </code></pre>