title: casting a floating to decimal in mysql
body: <p>I am not quite understanding the <code>cast</code> function and <code>decimal</code> here. What does <code>decimal(7,2)</code> actually mean?. <code>The first part and the second part arg of the function.</code></p>
  
  <p>Why do i need to <code>cast/convert</code> my floating point to decimal here?.</p>
  
  <pre><code>mysql&gt; SELECT productCode, MAX(price), MIN(price),
                CAST(AVG(price) AS DECIMAL(7,2)) AS `Average`,
                CAST(STD(price) AS DECIMAL(7,2)) AS `Std Dev`,
                SUM(quantity)
         FROM products
         GROUP BY productCode;
  +-------------+------------+------------+---------+---------+---------------+
  | productCode | MAX(price) | MIN(price) | Average | Std Dev | SUM(quantity) |
  +-------------+------------+------------+---------+---------+---------------+
  | PEC         |       0.49 |       0.48 |    0.49 |    0.01 |         18000 |
  | PEN         |       1.25 |       1.23 |    1.24 |    0.01 |         15000 |
  +-------------+------------+------------+---------+---------+---------------+
  </code></pre>
  
  <p>Below is a sql fiddle for the same?.</p>
  
  <p><a href="http://sqlfiddle.com/#!2/1ed51b/1/0" rel="nofollow">http://sqlfiddle.com/#!2/1ed51b/1/0</a></p>
  
  <p>My Questions again repeated:</p>
  
  <ol>
  <li>What does <code>decimal(7,2)</code> actually mean?. <code>The first part and the
  second part arg of the function.</code></li>
  <li>Why do i need to <code>cast/convert</code> my floating point to decimal here?.</li>
  </ol>