title: How do I force the column alias to be of specific data type?
body: <p>I have an alias in the select like this:</p>
  
  <pre><code>SELECT
      CASE ....
      WHEN 1 THEN somefield * -10
      WHEN 0 THEN somefield * 10
      END as myAlias
  FROM
      ....
  </code></pre>
  
  <p>the problem is that at the first record that mysql seeks, it marks the "myAlias" as UNSIGNED
  but in some next record the same alias produces a SIGNED integer, then I have the error:</p>
  
  <pre><code>BIGINT UNSIGNED value is out of range in....
  </code></pre>
  
  <p>so, how to tell mysql before it does any operation that "myAlias" is a SIGNED INTEGER?</p>
  
  <p>thanks!</p>
  
  <p>edit:</p>
  
  <p>I've tried</p>
  
  <pre><code>SELECT
      CAST(CASE ....
      WHEN 1 THEN somefield * -10
      WHEN 0 THEN somefield * 10
      END AS SIGNED) as myAlias
  FROM
      ....
  </code></pre>
  
  <p>without success!</p>