title: How do I change the data type of a calculated attribute in DML with PostgreSQL?
body: <p>Knowing that SQL Data Definition Language (DDL) Server Postgres (SP) can be used:</p>
  
  <ul>
  <li>CREATE </li>
  <li><strong>ALTER</strong> </li>
  <li>DROP</li>
  </ul>
  
  <p>And for SQL Data Manipulation Language (DML) SP:</p>
  
  <ul>
  <li>SELECT</li>
  <li>INSERT</li>
  <li>UPDATE </li>
  <li>DELETE</li>
  </ul>
  
  <p>When we make a <code>SELECT</code> the attributes that we project come in its type of data established in the DDL. And when performing an operation with 2 attributes of the same type to generate an attribute calculated in a <code>SELECT</code>, the type will be the same as that of the operands but I need to change it.</p>
  
  <p>My problem is that I want to calculate an average: <strong>A / B * 100</strong> between two types of data <code>bigint</code> but when I do A/B I obtain in the calculated field a 0, because I would need the decimal values also to multiply them by 100</p>
  
  <p>The following sql instruction does not work with <code>bigint</code>:</p>
  
  <pre><code>SELECT id, a/b
  FROM &lt;mytable&gt;;
  </code></pre>
  
  <p>This in the calculated field returns 0 values to me and is what I want to avoid.</p>
  
  <p>And what I would like to have is:</p>
  
  <pre><code>SELECT id, first_operand * 100
  FROM    (SELECT id, a/b TYPE &lt;newtype&gt; AS first_operand
          FROM &lt;mytable&gt;) firstTable
  NATURAL JOIN &lt;mytable&gt;;
  </code></pre>
  
  <p>So what I would like to know is how to change the type of data in a <code>SELECT</code> projection or what way do I have this?</p>