<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="mathematical-functions">
      </a>
      14.6.2 Mathematical Functions
     </h3>
    </div>
   </div>
  </div>
  <div class="table">
   <a name="idm46045206298160">
   </a>
   <p class="title">
    <b>
     Table 14.10 Mathematical Functions
    </b>
   </p>
   <div class="table-contents">
    <table frame="box" rules="all" summary="A reference that lists mathematical functions.">
     <colgroup>
      <col style="width: 28%"/>
      <col style="width: 71%"/>
     </colgroup>
     <thead>
      <tr>
       <th>
        Name
       </th>
       <th>
        Description
       </th>
      </tr>
     </thead>
     <tbody>
      <tr>
       <td>
        <a class="link" href="mathematical-functions.html#function_abs">
         <code class="literal">
          ABS()
         </code>
        </a>
       </td>
       <td>
        Return the absolute value
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="mathematical-functions.html#function_acos">
         <code class="literal">
          ACOS()
         </code>
        </a>
       </td>
       <td>
        Return the arc cosine
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="mathematical-functions.html#function_asin">
         <code class="literal">
          ASIN()
         </code>
        </a>
       </td>
       <td>
        Return the arc sine
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="mathematical-functions.html#function_atan">
         <code class="literal">
          ATAN()
         </code>
        </a>
       </td>
       <td>
        Return the arc tangent
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="mathematical-functions.html#function_atan2">
         <code class="literal">
          ATAN2()
         </code>
         ,
         <code class="literal">
          ATAN()
         </code>
        </a>
       </td>
       <td>
        Return the arc tangent of the two arguments
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="mathematical-functions.html#function_ceil">
         <code class="literal">
          CEIL()
         </code>
        </a>
       </td>
       <td>
        Return the smallest integer value not less than the argument
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="mathematical-functions.html#function_ceiling">
         <code class="literal">
          CEILING()
         </code>
        </a>
       </td>
       <td>
        Return the smallest integer value not less than the argument
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="mathematical-functions.html#function_conv">
         <code class="literal">
          CONV()
         </code>
        </a>
       </td>
       <td>
        Convert numbers between different number bases
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="mathematical-functions.html#function_cos">
         <code class="literal">
          COS()
         </code>
        </a>
       </td>
       <td>
        Return the cosine
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="mathematical-functions.html#function_cot">
         <code class="literal">
          COT()
         </code>
        </a>
       </td>
       <td>
        Return the cotangent
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="mathematical-functions.html#function_crc32">
         <code class="literal">
          CRC32()
         </code>
        </a>
       </td>
       <td>
        Compute a cyclic redundancy check value
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="mathematical-functions.html#function_degrees">
         <code class="literal">
          DEGREES()
         </code>
        </a>
       </td>
       <td>
        Convert radians to degrees
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="mathematical-functions.html#function_exp">
         <code class="literal">
          EXP()
         </code>
        </a>
       </td>
       <td>
        Raise to the power of
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="mathematical-functions.html#function_floor">
         <code class="literal">
          FLOOR()
         </code>
        </a>
       </td>
       <td>
        Return the largest integer value not greater than the argument
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="mathematical-functions.html#function_ln">
         <code class="literal">
          LN()
         </code>
        </a>
       </td>
       <td>
        Return the natural logarithm of the argument
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="mathematical-functions.html#function_log">
         <code class="literal">
          LOG()
         </code>
        </a>
       </td>
       <td>
        Return the natural logarithm of the first argument
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="mathematical-functions.html#function_log10">
         <code class="literal">
          LOG10()
         </code>
        </a>
       </td>
       <td>
        Return the base-10 logarithm of the argument
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="mathematical-functions.html#function_log2">
         <code class="literal">
          LOG2()
         </code>
        </a>
       </td>
       <td>
        Return the base-2 logarithm of the argument
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="mathematical-functions.html#function_mod">
         <code class="literal">
          MOD()
         </code>
        </a>
       </td>
       <td>
        Return the remainder
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="mathematical-functions.html#function_pi">
         <code class="literal">
          PI()
         </code>
        </a>
       </td>
       <td>
        Return the value of pi
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="mathematical-functions.html#function_pow">
         <code class="literal">
          POW()
         </code>
        </a>
       </td>
       <td>
        Return the argument raised to the specified power
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="mathematical-functions.html#function_power">
         <code class="literal">
          POWER()
         </code>
        </a>
       </td>
       <td>
        Return the argument raised to the specified power
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="mathematical-functions.html#function_radians">
         <code class="literal">
          RADIANS()
         </code>
        </a>
       </td>
       <td>
        Return argument converted to radians
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="mathematical-functions.html#function_rand">
         <code class="literal">
          RAND()
         </code>
        </a>
       </td>
       <td>
        Return a random floating-point value
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="mathematical-functions.html#function_round">
         <code class="literal">
          ROUND()
         </code>
        </a>
       </td>
       <td>
        Round the argument
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="mathematical-functions.html#function_sign">
         <code class="literal">
          SIGN()
         </code>
        </a>
       </td>
       <td>
        Return the sign of the argument
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="mathematical-functions.html#function_sin">
         <code class="literal">
          SIN()
         </code>
        </a>
       </td>
       <td>
        Return the sine of the argument
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="mathematical-functions.html#function_sqrt">
         <code class="literal">
          SQRT()
         </code>
        </a>
       </td>
       <td>
        Return the square root of the argument
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="mathematical-functions.html#function_tan">
         <code class="literal">
          TAN()
         </code>
        </a>
       </td>
       <td>
        Return the tangent of the argument
       </td>
      </tr>
      <tr>
       <td>
        <a class="link" href="mathematical-functions.html#function_truncate">
         <code class="literal">
          TRUNCATE()
         </code>
        </a>
       </td>
       <td>
        Truncate to specified number of decimal places
       </td>
      </tr>
     </tbody>
    </table>
   </div>
   <div class="table-contents">
    <table cellpadding="0" cellspacing="0" style="position: fixed; top: 0px; display: none; left: 401px; width: 567px;">
     <thead>
      <tr>
       <th style="width: 159.984px;">
        Name
       </th>
       <th style="width: 405.75px;">
        Description
       </th>
      </tr>
     </thead>
    </table>
   </div>
  </div>
  <br class="table-break"/>
  <p>
   All mathematical functions return
   <code class="literal">
    NULL
   </code>
   in the
        event of an error.
  </p>
  <a class="indexterm" name="idm46045206199728">
  </a>
  <a class="indexterm" name="idm46045206198656">
  </a>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <a name="function_abs">
     </a>
     <p>
      <a class="link" href="mathematical-functions.html#function_abs">
       <code class="literal">
        ABS(
        <em class="replaceable">
         <code>
          X
         </code>
        </em>
        )
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045206192256">
     </a>
     <p>
      Returns the absolute value of
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      ,
            or
      <code class="literal">
       NULL
      </code>
      if
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      is
      <code class="literal">
       NULL
      </code>
      .
     </p>
     <p>
      The result type is derived from the argument type. An
            implication of this is that
      <a class="link" href="mathematical-functions.html#function_abs">
       <code class="literal">
        ABS(-9223372036854775808)
       </code>
      </a>
      produces an error because the result cannot be stored in a
            signed
      <code class="literal">
       BIGINT
      </code>
      value.
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa89416677"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">ABS</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">2</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">ABS</span><span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">32</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">32</span></code></pre>
     </div>
     <p>
      This function is safe to use with
      <a class="link" href="integer-types.html" title="13.1.2 Integer Types (Exact Value) - INTEGER, INT, SMALLINT, TINYINT, MEDIUMINT, BIGINT">
       <code class="literal">
        BIGINT
       </code>
      </a>
      values.
     </p>
    </li>
    <li class="listitem">
     <a name="function_acos">
     </a>
     <p>
      <a class="link" href="mathematical-functions.html#function_acos">
       <code class="literal">
        ACOS(
        <em class="replaceable">
         <code>
          X
         </code>
        </em>
        )
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045206174912">
     </a>
     <p>
      Returns the arc cosine of
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      , that
            is, the value whose cosine is
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      .
            Returns
      <code class="literal">
       NULL
      </code>
      if
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      is not in the range
      <code class="literal">
       -1
      </code>
      to
      <code class="literal">
       1
      </code>
      , or if
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      is
      <code class="literal">
       NULL
      </code>
      .
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa12041012"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">ACOS</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">0</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">ACOS</span><span class="token punctuation">(</span><span class="token number">1.0001</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token boolean">NULL</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">ACOS</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">1.5707963267949</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <a name="function_asin">
     </a>
     <p>
      <a class="link" href="mathematical-functions.html#function_asin">
       <code class="literal">
        ASIN(
        <em class="replaceable">
         <code>
          X
         </code>
        </em>
        )
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045206158832">
     </a>
     <p>
      Returns the arc sine of
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      , that
            is, the value whose sine is
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      .
            Returns
      <code class="literal">
       NULL
      </code>
      if
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      is not in the range
      <code class="literal">
       -1
      </code>
      to
      <code class="literal">
       1
      </code>
      , or if
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      is
      <code class="literal">
       NULL
      </code>
      .
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa91024531"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">ASIN</span><span class="token punctuation">(</span><span class="token number">0.2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">0.20135792079033</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">ASIN</span><span class="token punctuation">(</span><span class="token string">'foo'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> ASIN('foo') <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span>           0 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">1 row in set, 1 warning (0.00 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">SHOW</span> <span class="token keyword">WARNINGS</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> Level   <span class="token punctuation">|</span> Code <span class="token punctuation">|</span> Message                                 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> Warning <span class="token punctuation">|</span> 1292 <span class="token punctuation">|</span> Truncated incorrect DOUBLE value: 'foo' <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <a name="function_atan">
     </a>
     <p>
      <a class="link" href="mathematical-functions.html#function_atan">
       <code class="literal">
        ATAN(
        <em class="replaceable">
         <code>
          X
         </code>
        </em>
        )
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045206142176">
     </a>
     <p>
      Returns the arc tangent of
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      ,
            that is, the value whose tangent is
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      . Returns
      <em class="replaceable">
       <code>
        NULL
       </code>
      </em>
      if
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      is
      <code class="literal">
       NULL
      </code>
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa19697008"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">ATAN</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">1.1071487177941</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">ATAN</span><span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token operator">-</span><span class="token number">1.1071487177941</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <a name="function_atan2">
     </a>
     <p>
      <a class="link" href="mathematical-functions.html#function_atan2">
       <code class="literal">
        ATAN(
        <em class="replaceable">
         <code>
          Y
         </code>
        </em>
        ,
        <em class="replaceable">
         <code>
          X
         </code>
        </em>
        )
       </code>
      </a>
      ,
      <a class="link" href="mathematical-functions.html#function_atan2">
       <code class="literal">
        ATAN2(
        <em class="replaceable">
         <code>
          Y
         </code>
        </em>
        ,
        <em class="replaceable">
         <code>
          X
         </code>
        </em>
        )
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045206126400">
     </a>
     <p>
      Returns the arc tangent of the two variables
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      and
      <em class="replaceable">
       <code>
        Y
       </code>
      </em>
      . It is similar to calculating
            the arc tangent of
      <code class="literal">
       <em class="replaceable">
        <code>
         Y
        </code>
       </em>
       /
       <em class="replaceable">
        <code>
         X
        </code>
       </em>
      </code>
      , except that the
            signs of both arguments are used to determine the quadrant
            of the result. Returns
      <code class="literal">
       NULL
      </code>
      if
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      or
      <em class="replaceable">
       <code>
        Y
       </code>
      </em>
      is
      <code class="literal">
       NULL
      </code>
      .
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa70785433"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">ATAN</span><span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token operator">-</span><span class="token number">0.78539816339745</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">ATAN2</span><span class="token punctuation">(</span><span class="token function">PI</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">1.5707963267949</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <a name="function_ceil">
     </a>
     <p>
      <a class="link" href="mathematical-functions.html#function_ceil">
       <code class="literal">
        CEIL(
        <em class="replaceable">
         <code>
          X
         </code>
        </em>
        )
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045206110928">
     </a>
     <p>
      <a class="link" href="mathematical-functions.html#function_ceil">
       <code class="literal">
        CEIL()
       </code>
      </a>
      is a synonym for
      <a class="link" href="mathematical-functions.html#function_ceiling">
       <code class="literal">
        CEILING()
       </code>
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <a name="function_ceiling">
     </a>
     <p>
      <a class="link" href="mathematical-functions.html#function_ceiling">
       <code class="literal">
        CEILING(
        <em class="replaceable">
         <code>
          X
         </code>
        </em>
        )
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045206100592">
     </a>
     <p>
      Returns the smallest integer value not less than
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      . Returns
      <code class="literal">
       NULL
      </code>
      if
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      is
      <code class="literal">
       NULL
      </code>
      .
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa30094610"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">CEILING</span><span class="token punctuation">(</span><span class="token number">1.23</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">2</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">CEILING</span><span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1.23</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token operator">-</span><span class="token number">1</span></code></pre>
     </div>
     <p>
      For exact-value numeric arguments, the return value has an
            exact-value numeric type. For string or floating-point
            arguments, the return value has a floating-point type.
     </p>
    </li>
    <li class="listitem">
     <a name="function_conv">
     </a>
     <p>
      <a class="link" href="mathematical-functions.html#function_conv">
       <code class="literal">
        CONV(
        <em class="replaceable">
         <code>
          N
         </code>
        </em>
        ,
        <em class="replaceable">
         <code>
          from_base
         </code>
        </em>
        ,
        <em class="replaceable">
         <code>
          to_base
         </code>
        </em>
        )
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045206086016">
     </a>
     <p>
      Converts numbers between different number bases. Returns a
            string representation of the number
      <em class="replaceable">
       <code>
        N
       </code>
      </em>
      , converted from base
      <em class="replaceable">
       <code>
        from_base
       </code>
      </em>
      to base
      <em class="replaceable">
       <code>
        to_base
       </code>
      </em>
      . Returns
      <code class="literal">
       NULL
      </code>
      if any argument is
      <code class="literal">
       NULL
      </code>
      . The argument
      <em class="replaceable">
       <code>
        N
       </code>
      </em>
      is interpreted as an integer,
            but may be specified as an integer or a string. The minimum
            base is
      <code class="literal">
       2
      </code>
      and the maximum base is
      <code class="literal">
       36
      </code>
      . If
      <em class="replaceable">
       <code>
        from_base
       </code>
      </em>
      is a negative number,
      <em class="replaceable">
       <code>
        N
       </code>
      </em>
      is regarded as a signed number.
            Otherwise,
      <em class="replaceable">
       <code>
        N
       </code>
      </em>
      is treated as
            unsigned.
      <a class="link" href="mathematical-functions.html#function_conv">
       <code class="literal">
        CONV()
       </code>
      </a>
      works with
            64-bit precision.
     </p>
     <p>
      <code class="literal">
       CONV()
      </code>
      returns
      <code class="literal">
       NULL
      </code>
      if
            any of its arguments are
      <code class="literal">
       NULL
      </code>
      .
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa84765985"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">CONV</span><span class="token punctuation">(</span><span class="token string">'a'</span><span class="token punctuation">,</span><span class="token number">16</span><span class="token punctuation">,</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token string">'1010'</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">CONV</span><span class="token punctuation">(</span><span class="token string">'6E'</span><span class="token punctuation">,</span><span class="token number">18</span><span class="token punctuation">,</span><span class="token number">8</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token string">'172'</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">CONV</span><span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">17</span><span class="token punctuation">,</span><span class="token number">10</span><span class="token punctuation">,</span><span class="token operator">-</span><span class="token number">18</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token string">'-H'</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">CONV</span><span class="token punctuation">(</span><span class="token number">10</span><span class="token operator">+</span><span class="token string">'10'</span><span class="token operator">+</span><span class="token string">'10'</span><span class="token operator">+</span>X<span class="token string">'0a'</span><span class="token punctuation">,</span><span class="token number">10</span><span class="token punctuation">,</span><span class="token number">10</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token string">'40'</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <a name="function_cos">
     </a>
     <p>
      <a class="link" href="mathematical-functions.html#function_cos">
       <code class="literal">
        COS(
        <em class="replaceable">
         <code>
          X
         </code>
        </em>
        )
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045206063536">
     </a>
     <p>
      Returns the cosine of
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      , where
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      is given in radians. Returns
      <code class="literal">
       NULL
      </code>
      if
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      is
      <code class="literal">
       NULL
      </code>
      .
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa21994635"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">COS</span><span class="token punctuation">(</span><span class="token function">PI</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token operator">-</span><span class="token number">1</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <a name="function_cot">
     </a>
     <p>
      <a class="link" href="mathematical-functions.html#function_cot">
       <code class="literal">
        COT(
        <em class="replaceable">
         <code>
          X
         </code>
        </em>
        )
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045206050720">
     </a>
     <p>
      Returns the cotangent of
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      .
            Returns
      <code class="literal">
       NULL
      </code>
      if
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      is
      <code class="literal">
       NULL
      </code>
      .
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa93349708"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">COT</span><span class="token punctuation">(</span><span class="token number">12</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token operator">-</span><span class="token number">1.5726734063977</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">COT</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token keyword">out</span><span class="token operator">-</span><span class="token keyword">of</span><span class="token operator">-</span><span class="token keyword">range</span> <span class="token keyword">error</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <a name="function_crc32">
     </a>
     <p>
      <a class="link" href="mathematical-functions.html#function_crc32">
       <code class="literal">
        CRC32(
        <em class="replaceable">
         <code>
          expr
         </code>
        </em>
        )
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045206037472">
     </a>
     <p>
      Computes a cyclic redundancy check value and returns a
            32-bit unsigned value. The result is
      <code class="literal">
       NULL
      </code>
      if the argument is
      <code class="literal">
       NULL
      </code>
      . The argument is
            expected to be a string and (if possible) is treated as one
            if it is not.
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa11360596"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">CRC32</span><span class="token punctuation">(</span><span class="token string">'MySQL'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">3259397556</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">CRC32</span><span class="token punctuation">(</span><span class="token string">'mysql'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">2501908538</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <a name="function_degrees">
     </a>
     <p>
      <a class="link" href="mathematical-functions.html#function_degrees">
       <code class="literal">
        DEGREES(
        <em class="replaceable">
         <code>
          X
         </code>
        </em>
        )
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045206024960">
     </a>
     <p>
      Returns the argument
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      , converted
            from radians to degrees. Returns
      <code class="literal">
       NULL
      </code>
      if
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      is
      <code class="literal">
       NULL
      </code>
      .
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa61168688"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">DEGREES</span><span class="token punctuation">(</span><span class="token function">PI</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">180</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">DEGREES</span><span class="token punctuation">(</span><span class="token function">PI</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">/</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">90</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <a name="function_exp">
     </a>
     <p>
      <a class="link" href="mathematical-functions.html#function_exp">
       <code class="literal">
        EXP(
        <em class="replaceable">
         <code>
          X
         </code>
        </em>
        )
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045206011808">
     </a>
     <p>
      Returns the value of
      <span class="emphasis">
       <em>
        e
       </em>
      </span>
      (the base of
            natural logarithms) raised to the power of
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      . The inverse of this function
            is
      <a class="link" href="mathematical-functions.html#function_log">
       <code class="literal">
        LOG()
       </code>
      </a>
      (using a single
            argument only) or
      <a class="link" href="mathematical-functions.html#function_ln">
       <code class="literal">
        LN()
       </code>
      </a>
      .
     </p>
     <p>
      If
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      is
      <code class="literal">
       NULL
      </code>
      ,
            this function returns
      <code class="literal">
       NULL
      </code>
      .
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa4129655"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">EXP</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">7.3890560989307</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">EXP</span><span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">0.13533528323661</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">EXP</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">1</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <a name="function_floor">
     </a>
     <p>
      <a class="link" href="mathematical-functions.html#function_floor">
       <code class="literal">
        FLOOR(
        <em class="replaceable">
         <code>
          X
         </code>
        </em>
        )
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045205994416">
     </a>
     <p>
      Returns the largest integer value not greater than
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      . Returns
      <code class="literal">
       NULL
      </code>
      if
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      is
      <code class="literal">
       NULL
      </code>
      .
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa46978986"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">FLOOR</span><span class="token punctuation">(</span><span class="token number">1.23</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">FLOOR</span><span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1.23</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token operator">-</span><span class="token number">2</span></code></pre>
     </div>
     <p>
      For exact-value numeric arguments, the return value has an
            exact-value numeric type. For string or floating-point
            arguments, the return value has a floating-point type.
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="link" href="string-functions.html#function_format">
       <code class="literal">
        FORMAT(
        <em class="replaceable">
         <code>
          X
         </code>
        </em>
        ,
        <em class="replaceable">
         <code>
          D
         </code>
        </em>
        )
       </code>
      </a>
     </p>
     <p>
      Formats the number
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      to a format
            like
      <code class="literal">
       '#,###,###.##'
      </code>
      , rounded to
      <em class="replaceable">
       <code>
        D
       </code>
      </em>
      decimal places, and returns the
            result as a string. For details, see
      <a class="xref" href="string-functions.html" title="14.8 String Functions and Operators">
       Section 14.8, “String Functions and Operators”
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="indexterm" name="idm46045205978320">
      </a>
      <a class="link" href="string-functions.html#function_hex">
       <code class="literal">
        HEX(N_or_S)
       </code>
      </a>
     </p>
     <p>
      This function can be used to obtain a hexadecimal
            representation of a decimal number or a string; the manner
            in which it does so varies according to the argument's
            type. See this function's description in
      <a class="xref" href="string-functions.html" title="14.8 String Functions and Operators">
       Section 14.8, “String Functions and Operators”
      </a>
      , for details.
     </p>
    </li>
    <li class="listitem">
     <a name="function_ln">
     </a>
     <p>
      <a class="link" href="mathematical-functions.html#function_ln">
       <code class="literal">
        LN(
        <em class="replaceable">
         <code>
          X
         </code>
        </em>
        )
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045205969712">
     </a>
     <p>
      Returns the natural logarithm of
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      ; that is, the
            base-
      <span class="emphasis">
       <em>
        e
       </em>
      </span>
      logarithm of
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      . If
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      is less than or equal to 0.0E0,
            the function returns
      <code class="literal">
       NULL
      </code>
      and a warning
      <span class="quote">
       “
       <span class="quote">
        Invalid argument for logarithm
       </span>
       ”
      </span>
      is reported.
            Returns
      <code class="literal">
       NULL
      </code>
      if
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      is
      <code class="literal">
       NULL
      </code>
      .
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa84010264"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">LN</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">0.69314718055995</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">LN</span><span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token boolean">NULL</span></code></pre>
     </div>
     <p>
      This function is synonymous with
      <a class="link" href="mathematical-functions.html#function_log">
       <code class="literal">
        LOG(
        <em class="replaceable">
         <code>
          X
         </code>
        </em>
        )
       </code>
      </a>
      .
            The inverse of this function is the
      <a class="link" href="mathematical-functions.html#function_exp">
       <code class="literal">
        EXP()
       </code>
      </a>
      function.
     </p>
    </li>
    <li class="listitem">
     <a name="function_log">
     </a>
     <p>
      <a class="link" href="mathematical-functions.html#function_log">
       <code class="literal">
        LOG(
        <em class="replaceable">
         <code>
          X
         </code>
        </em>
        )
       </code>
      </a>
      ,
      <a class="link" href="mathematical-functions.html#function_log">
       <code class="literal">
        LOG(
        <em class="replaceable">
         <code>
          B
         </code>
        </em>
        ,
        <em class="replaceable">
         <code>
          X
         </code>
        </em>
        )
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045205948656">
     </a>
     <p>
      If called with one parameter, this function returns the
            natural logarithm of
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      . If
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      is less than or equal to 0.0E0,
            the function returns
      <code class="literal">
       NULL
      </code>
      and a warning
      <span class="quote">
       “
       <span class="quote">
        Invalid argument for logarithm
       </span>
       ”
      </span>
      is reported.
            Returns
      <code class="literal">
       NULL
      </code>
      if
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      or
      <em class="replaceable">
       <code>
        B
       </code>
      </em>
      is
      <code class="literal">
       NULL
      </code>
      .
     </p>
     <p>
      The inverse of this function (when called with a single
            argument) is the
      <a class="link" href="mathematical-functions.html#function_exp">
       <code class="literal">
        EXP()
       </code>
      </a>
      function.
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa74482526"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">LOG</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">0.69314718055995</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">LOG</span><span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token boolean">NULL</span></code></pre>
     </div>
     <p>
      If called with two parameters, this function returns the
            logarithm of
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      to the base
      <em class="replaceable">
       <code>
        B
       </code>
      </em>
      . If
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      is less than or equal to 0, or
            if
      <em class="replaceable">
       <code>
        B
       </code>
      </em>
      is less than or equal to 1,
            then
      <code class="literal">
       NULL
      </code>
      is returned.
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa57751811"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">LOG</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token number">65536</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">16</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">LOG</span><span class="token punctuation">(</span><span class="token number">10</span><span class="token punctuation">,</span><span class="token number">100</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">2</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">LOG</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token number">100</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token boolean">NULL</span></code></pre>
     </div>
     <p>
      <a class="link" href="mathematical-functions.html#function_log">
       <code class="literal">
        LOG(
        <em class="replaceable">
         <code>
          B
         </code>
        </em>
        ,
        <em class="replaceable">
         <code>
          X
         </code>
        </em>
        )
       </code>
      </a>
      is equivalent to
      <a class="link" href="mathematical-functions.html#function_log">
       <code class="literal">
        LOG(
        <em class="replaceable">
         <code>
          X
         </code>
        </em>
        ) /
            LOG(
        <em class="replaceable">
         <code>
          B
         </code>
        </em>
        )
       </code>
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <a name="function_log2">
     </a>
     <p>
      <a class="link" href="mathematical-functions.html#function_log2">
       <code class="literal">
        LOG2(
        <em class="replaceable">
         <code>
          X
         </code>
        </em>
        )
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045205921088">
     </a>
     <p>
      Returns the base-2 logarithm of
      <code class="literal">
       <em class="replaceable">
        <code>
         X
        </code>
       </em>
      </code>
      . If
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      is less than or equal to 0.0E0,
            the function returns
      <code class="literal">
       NULL
      </code>
      and a warning
      <span class="quote">
       “
       <span class="quote">
        Invalid argument for logarithm
       </span>
       ”
      </span>
      is reported.
            Returns
      <code class="literal">
       NULL
      </code>
      if
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      is
      <code class="literal">
       NULL
      </code>
      .
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa51217433"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">LOG2</span><span class="token punctuation">(</span><span class="token number">65536</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">16</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">LOG2</span><span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">100</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token boolean">NULL</span></code></pre>
     </div>
     <p>
      <a class="link" href="mathematical-functions.html#function_log2">
       <code class="literal">
        LOG2()
       </code>
      </a>
      is useful for finding
            out how many bits a number requires for storage. This
            function is equivalent to the expression
      <a class="link" href="mathematical-functions.html#function_log">
       <code class="literal">
        LOG(
        <em class="replaceable">
         <code>
          X
         </code>
        </em>
        ) /
            LOG(2)
       </code>
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <a name="function_log10">
     </a>
     <p>
      <a class="link" href="mathematical-functions.html#function_log10">
       <code class="literal">
        LOG10(
        <em class="replaceable">
         <code>
          X
         </code>
        </em>
        )
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045205902496">
     </a>
     <p>
      Returns the base-10 logarithm of
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      . If
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      is less than or equal to 0.0E0,
            the function returns
      <code class="literal">
       NULL
      </code>
      and a warning
      <span class="quote">
       “
       <span class="quote">
        Invalid argument for logarithm
       </span>
       ”
      </span>
      is reported.
            Returns
      <code class="literal">
       NULL
      </code>
      if
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      is
      <code class="literal">
       NULL
      </code>
      .
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa66072306"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">LOG10</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">0.30102999566398</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">LOG10</span><span class="token punctuation">(</span><span class="token number">100</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">2</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">LOG10</span><span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">100</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token boolean">NULL</span></code></pre>
     </div>
     <p>
      <a class="link" href="mathematical-functions.html#function_log10">
       <code class="literal">
        LOG10(
        <em class="replaceable">
         <code>
          X
         </code>
        </em>
        )
       </code>
      </a>
      is equivalent to
      <a class="link" href="mathematical-functions.html#function_log">
       <code class="literal">
        LOG(10,
        <em class="replaceable">
         <code>
          X
         </code>
        </em>
        )
       </code>
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <a name="function_mod">
     </a>
     <p>
      <a class="link" href="mathematical-functions.html#function_mod">
       <code class="literal">
        MOD(
        <em class="replaceable">
         <code>
          N
         </code>
        </em>
        ,
        <em class="replaceable">
         <code>
          M
         </code>
        </em>
        )
       </code>
      </a>
      ,
      <a class="link" href="arithmetic-functions.html#operator_mod">
       <code class="literal">
        <em class="replaceable">
         <code>
          N
         </code>
        </em>
        %
        <em class="replaceable">
         <code>
          M
         </code>
        </em>
       </code>
      </a>
      ,
      <a class="link" href="arithmetic-functions.html#operator_mod">
       <code class="literal">
        <em class="replaceable">
         <code>
          N
         </code>
        </em>
        MOD
        <em class="replaceable">
         <code>
          M
         </code>
        </em>
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045205879424">
     </a>
     <a class="indexterm" name="idm46045205878352">
     </a>
     <a class="indexterm" name="idm46045205877280">
     </a>
     <a class="indexterm" name="idm46045205876208">
     </a>
     <a class="indexterm" name="idm46045205875136">
     </a>
     <p>
      Modulo operation. Returns the remainder of
      <em class="replaceable">
       <code>
        N
       </code>
      </em>
      divided by
      <em class="replaceable">
       <code>
        M
       </code>
      </em>
      . Returns
      <code class="literal">
       NULL
      </code>
      if
      <em class="replaceable">
       <code>
        M
       </code>
      </em>
      or
      <em class="replaceable">
       <code>
        N
       </code>
      </em>
      is
      <code class="literal">
       NULL
      </code>
      .
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa7111243"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">MOD</span><span class="token punctuation">(</span><span class="token number">234</span><span class="token punctuation">,</span> <span class="token number">10</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">4</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token number">253</span> <span class="token operator">%</span> <span class="token number">7</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">1</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">MOD</span><span class="token punctuation">(</span><span class="token number">29</span><span class="token punctuation">,</span><span class="token number">9</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">2</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token number">29</span> <span class="token operator">MOD</span> <span class="token number">9</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">2</span></code></pre>
     </div>
     <p>
      This function is safe to use with
      <a class="link" href="integer-types.html" title="13.1.2 Integer Types (Exact Value) - INTEGER, INT, SMALLINT, TINYINT, MEDIUMINT, BIGINT">
       <code class="literal">
        BIGINT
       </code>
      </a>
      values.
     </p>
     <p>
      <a class="link" href="mathematical-functions.html#function_mod">
       <code class="literal">
        MOD()
       </code>
      </a>
      also works on values
            that have a fractional part and returns the exact remainder
            after division:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa72035516"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">MOD</span><span class="token punctuation">(</span><span class="token number">34.5</span><span class="token punctuation">,</span><span class="token number">3</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">1.5</span></code></pre>
     </div>
     <p>
      <a class="link" href="mathematical-functions.html#function_mod">
       <code class="literal">
        MOD(
        <em class="replaceable">
         <code>
          N
         </code>
        </em>
        ,0)
       </code>
      </a>
      returns
      <code class="literal">
       NULL
      </code>
      .
     </p>
    </li>
    <li class="listitem">
     <a name="function_pi">
     </a>
     <p>
      <a class="link" href="mathematical-functions.html#function_pi">
       <code class="literal">
        PI()
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045205852368">
     </a>
     <p>
      Returns the value of π (pi). The default number of
            decimal places displayed is seven, but MySQL uses the full
            double-precision value internally.
     </p>
     <p>
      Because the return value of this function is a
            double-precision value, its exact representation may vary
            between platforms or implementations. This also applies to
            any expressions making use of
      <code class="literal">
       PI()
      </code>
      . See
      <a class="xref" href="floating-point-types.html" title="13.1.4 Floating-Point Types (Approximate Value) - FLOAT, DOUBLE">
       Section 13.1.4, “Floating-Point Types (Approximate Value) - FLOAT, DOUBLE”
      </a>
      .
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa6181439"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">PI</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">3.141593</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">PI</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">+</span><span class="token number">0.000000000000000000</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">3.141592653589793000</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <a name="function_pow">
     </a>
     <p>
      <a class="link" href="mathematical-functions.html#function_pow">
       <code class="literal">
        POW(
        <em class="replaceable">
         <code>
          X
         </code>
        </em>
        ,
        <em class="replaceable">
         <code>
          Y
         </code>
        </em>
        )
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045205838624">
     </a>
     <p>
      Returns the value of
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      raised to
            the power of
      <em class="replaceable">
       <code>
        Y
       </code>
      </em>
      . Returns
      <code class="literal">
       NULL
      </code>
      if
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      or
      <em class="replaceable">
       <code>
        Y
       </code>
      </em>
      is
      <code class="literal">
       NULL
      </code>
      .
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa39957762"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">POW</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">4</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">POW</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token operator">-</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">0.25</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <a name="function_power">
     </a>
     <p>
      <a class="link" href="mathematical-functions.html#function_power">
       <code class="literal">
        POWER(
        <em class="replaceable">
         <code>
          X
         </code>
        </em>
        ,
        <em class="replaceable">
         <code>
          Y
         </code>
        </em>
        )
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045205824320">
     </a>
     <p>
      This is a synonym for
      <a class="link" href="mathematical-functions.html#function_pow">
       <code class="literal">
        POW()
       </code>
      </a>
      .
     </p>
    </li>
    <li class="listitem">
     <a name="function_radians">
     </a>
     <p>
      <a class="link" href="mathematical-functions.html#function_radians">
       <code class="literal">
        RADIANS(
        <em class="replaceable">
         <code>
          X
         </code>
        </em>
        )
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045205815184">
     </a>
     <p>
      Returns the argument
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      , converted
            from degrees to radians. (Note that π radians equals 180
            degrees.) Returns
      <code class="literal">
       NULL
      </code>
      if
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      is
      <code class="literal">
       NULL
      </code>
      .
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa10199580"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">RADIANS</span><span class="token punctuation">(</span><span class="token number">90</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">1.5707963267949</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <a name="function_rand">
     </a>
     <p>
      <a class="link" href="mathematical-functions.html#function_rand">
       <code class="literal">
        RAND([
        <em class="replaceable">
         <code>
          N
         </code>
        </em>
        ])
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045205802560">
     </a>
     <p>
      Returns a random floating-point value
      <em class="replaceable">
       <code>
        v
       </code>
      </em>
      in the range
      <code class="literal">
       0
      </code>
      &lt;=
      <em class="replaceable">
       <code>
        v
       </code>
      </em>
      &lt;
      <code class="literal">
       1.0
      </code>
      . To obtain a random integer
      <em class="replaceable">
       <code>
        R
       </code>
      </em>
      in the range
      <em class="replaceable">
       <code>
        i
       </code>
      </em>
      &lt;=
      <em class="replaceable">
       <code>
        R
       </code>
      </em>
      &lt;
      <em class="replaceable">
       <code>
        j
       </code>
      </em>
      , use the expression
      <a class="link" href="mathematical-functions.html#function_floor">
       <code class="literal">
        FLOOR(
        <em class="replaceable">
         <code>
          i
         </code>
        </em>
        + RAND() * (
        <em class="replaceable">
         <code>
          j
         </code>
        </em>
       </code>
      </a>
      −
      <code class="literal">
       <em class="replaceable">
        <code>
         i
        </code>
       </em>
       ))
      </code>
      .
            For example, to obtain a random integer in the range the
            range
      <code class="literal">
       7
      </code>
      &lt;=
      <em class="replaceable">
       <code>
        R
       </code>
      </em>
      &lt;
      <code class="literal">
       12
      </code>
      , use
            the following statement:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa86321183"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token function">FLOOR</span><span class="token punctuation">(</span><span class="token number">7</span> <span class="token operator">+</span> <span class="token punctuation">(</span><span class="token function">RAND</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">*</span> <span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
     </div>
     <p>
      If an integer argument
      <em class="replaceable">
       <code>
        N
       </code>
      </em>
      is
            specified, it is used as the seed value:
     </p>
     <div class="itemizedlist">
      <ul class="itemizedlist" style="list-style-type: circle; ">
       <li class="listitem">
        <p>
         With a constant initializer argument, the seed is
                initialized once when the statement is prepared, prior
                to execution.
        </p>
       </li>
       <li class="listitem">
        <p>
         With a nonconstant initializer argument (such as a
                column name), the seed is initialized with the value for
                each invocation of
         <a class="link" href="mathematical-functions.html#function_rand">
          <code class="literal">
           RAND()
          </code>
         </a>
         .
        </p>
       </li>
      </ul>
     </div>
     <p>
      One implication of this behavior is that for equal argument
            values,
      <a class="link" href="mathematical-functions.html#function_rand">
       <code class="literal">
        RAND(
        <em class="replaceable">
         <code>
          N
         </code>
        </em>
        )
       </code>
      </a>
      returns the same value each time, and thus produces a
            repeatable sequence of column values. In the following
            example, the sequence of values produced by
      <code class="literal">
       RAND(3)
      </code>
      is the same both places it
            occurs.
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa31818123"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> t <span class="token punctuation">(</span>i <span class="token datatype">INT</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.42 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> t <span class="token keyword">VALUES</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token punctuation">(</span><span class="token number">3</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 3 rows affected (0.00 sec)</span>
<span class="token output">Records: 3  Duplicates: 0  Warnings: 0</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> i<span class="token punctuation">,</span> <span class="token function">RAND</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token keyword">FROM</span> t<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> i    <span class="token punctuation">|</span> RAND()           <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span>    1 <span class="token punctuation">|</span> 0.61914388706828 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span>    2 <span class="token punctuation">|</span> 0.93845168309142 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span>    3 <span class="token punctuation">|</span> 0.83482678498591 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">3 rows in set (0.00 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> i<span class="token punctuation">,</span> <span class="token function">RAND</span><span class="token punctuation">(</span><span class="token number">3</span><span class="token punctuation">)</span> <span class="token keyword">FROM</span> t<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> i    <span class="token punctuation">|</span> RAND(3)          <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span>    1 <span class="token punctuation">|</span> 0.90576975597606 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span>    2 <span class="token punctuation">|</span> 0.37307905813035 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span>    3 <span class="token punctuation">|</span> 0.14808605345719 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">3 rows in set (0.00 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> i<span class="token punctuation">,</span> <span class="token function">RAND</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token keyword">FROM</span> t<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> i    <span class="token punctuation">|</span> RAND()           <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span>    1 <span class="token punctuation">|</span> 0.35877890638893 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span>    2 <span class="token punctuation">|</span> 0.28941420772058 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span>    3 <span class="token punctuation">|</span> 0.37073435016976 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">3 rows in set (0.00 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> i<span class="token punctuation">,</span> <span class="token function">RAND</span><span class="token punctuation">(</span><span class="token number">3</span><span class="token punctuation">)</span> <span class="token keyword">FROM</span> t<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> i    <span class="token punctuation">|</span> RAND(3)          <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span>    1 <span class="token punctuation">|</span> 0.90576975597606 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span>    2 <span class="token punctuation">|</span> 0.37307905813035 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span>    3 <span class="token punctuation">|</span> 0.14808605345719 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">3 rows in set (0.01 sec)</span></code></pre>
     </div>
     <p>
      <a class="link" href="mathematical-functions.html#function_rand">
       <code class="literal">
        RAND()
       </code>
      </a>
      in a
      <code class="literal">
       WHERE
      </code>
      clause is evaluated for every row
            (when selecting from one table) or combination of rows (when
            selecting from a multiple-table join). Thus, for optimizer
            purposes,
      <a class="link" href="mathematical-functions.html#function_rand">
       <code class="literal">
        RAND()
       </code>
      </a>
      is not a
            constant value and cannot be used for index optimizations.
            For more information, see
      <a class="xref" href="function-optimization.html" title="10.2.1.20 Function Call Optimization">
       Section 10.2.1.20, “Function Call Optimization”
      </a>
      .
     </p>
     <p>
      Use of a column with
      <a class="link" href="mathematical-functions.html#function_rand">
       <code class="literal">
        RAND()
       </code>
      </a>
      values in an
      <code class="literal">
       ORDER BY
      </code>
      or
      <code class="literal">
       GROUP
            BY
      </code>
      clause may yield unexpected results because for
            either clause a
      <a class="link" href="mathematical-functions.html#function_rand">
       <code class="literal">
        RAND()
       </code>
      </a>
      expression can be evaluated multiple times for the same row,
            each time returning a different result. If the goal is to
            retrieve rows in random order, you can use a statement like
            this:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa45106447"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> <em class="replaceable">tbl_name</em> <span class="token keyword">ORDER</span> <span class="token keyword">BY</span> <span class="token function">RAND</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
     </div>
     <p>
      To select a random sample from a set of rows, combine
      <code class="literal">
       ORDER BY RAND()
      </code>
      with
      <code class="literal">
       LIMIT
      </code>
      :
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa38489810"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> table1<span class="token punctuation">,</span> table2 <span class="token keyword">WHERE</span> a<span class="token operator">=</span>b <span class="token operator">AND</span> c<span class="token operator">&lt;</span>d <span class="token keyword">ORDER</span> <span class="token keyword">BY</span> <span class="token function">RAND</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token keyword">LIMIT</span> <span class="token number">1000</span><span class="token punctuation">;</span></code></pre>
     </div>
     <p>
      <a class="link" href="mathematical-functions.html#function_rand">
       <code class="literal">
        RAND()
       </code>
      </a>
      is not meant to be a
            perfect random generator. It is a fast way to generate
            random numbers on demand that is portable between platforms
            for the same MySQL version.
     </p>
     <p>
      This function is unsafe for statement-based replication. A
            warning is logged if you use this function when
      <a class="link" href="replication-options-binary-log.html#sysvar_binlog_format">
       <code class="literal">
        binlog_format
       </code>
      </a>
      is set to
      <code class="literal">
       STATEMENT
      </code>
      .
     </p>
    </li>
    <li class="listitem">
     <a name="function_round">
     </a>
     <p>
      <a class="link" href="mathematical-functions.html#function_round">
       <code class="literal">
        ROUND(
        <em class="replaceable">
         <code>
          X
         </code>
        </em>
        )
       </code>
      </a>
      ,
      <a class="link" href="mathematical-functions.html#function_round">
       <code class="literal">
        ROUND(
        <em class="replaceable">
         <code>
          X
         </code>
        </em>
        ,
        <em class="replaceable">
         <code>
          D
         </code>
        </em>
        )
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045205749680">
     </a>
     <p>
      Rounds the argument
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      to
      <em class="replaceable">
       <code>
        D
       </code>
      </em>
      decimal places. The rounding
            algorithm depends on the data type of
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      .
      <em class="replaceable">
       <code>
        D
       </code>
      </em>
      defaults to 0 if not specified.
      <em class="replaceable">
       <code>
        D
       </code>
      </em>
      can be negative to cause
      <em class="replaceable">
       <code>
        D
       </code>
      </em>
      digits
            left of the decimal point of the value
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      to become zero. The maximum
            absolute value for
      <em class="replaceable">
       <code>
        D
       </code>
      </em>
      is 30; any
            digits in excess of 30 (or -30) are truncated. If
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      or
      <em class="replaceable">
       <code>
        D
       </code>
      </em>
      is
      <code class="literal">
       NULL
      </code>
      , the function returns
      <code class="literal">
       NULL
      </code>
      .
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa74543640"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">ROUND</span><span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1.23</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token operator">-</span><span class="token number">1</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">ROUND</span><span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1.58</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token operator">-</span><span class="token number">2</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">ROUND</span><span class="token punctuation">(</span><span class="token number">1.58</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">2</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">ROUND</span><span class="token punctuation">(</span><span class="token number">1.298</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">1.3</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">ROUND</span><span class="token punctuation">(</span><span class="token number">1.298</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">1</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">ROUND</span><span class="token punctuation">(</span><span class="token number">23.298</span><span class="token punctuation">,</span> <span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">20</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">ROUND</span><span class="token punctuation">(</span><span class="token punctuation">.</span><span class="token number">12345678901234567890123456789012345</span><span class="token punctuation">,</span> <span class="token number">35</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">0.123456789012345678901234567890</span></code></pre>
     </div>
     <p>
      The return value has the same type as the first argument
            (assuming that it is integer, double, or decimal). This
            means that for an integer argument, the result is an integer
            (no decimal places):
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa62222484"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">ROUND</span><span class="token punctuation">(</span><span class="token number">150.000</span><span class="token punctuation">,</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">ROUND</span><span class="token punctuation">(</span><span class="token number">150</span><span class="token punctuation">,</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> ROUND(150.000,2) <span class="token punctuation">|</span> ROUND(150,2) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span>           150.00 <span class="token punctuation">|</span>          150 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
     </div>
     <p>
      <a class="link" href="mathematical-functions.html#function_round">
       <code class="literal">
        ROUND()
       </code>
      </a>
      uses the following
            rules depending on the type of the first argument:
     </p>
     <div class="itemizedlist">
      <ul class="itemizedlist" style="list-style-type: circle; ">
       <li class="listitem">
        <p>
         For exact-value numbers,
         <a class="link" href="mathematical-functions.html#function_round">
          <code class="literal">
           ROUND()
          </code>
         </a>
         uses the
         <span class="quote">
          “
          <span class="quote">
           round half away from zero
          </span>
          ”
         </span>
         or
         <span class="quote">
          “
          <span class="quote">
           round
                toward nearest
          </span>
          ”
         </span>
         rule: A value with a fractional
                part of .5 or greater is rounded up to the next integer
                if positive or down to the next integer if negative. (In
                other words, it is rounded away from zero.) A value with
                a fractional part less than .5 is rounded down to the
                next integer if positive or up to the next integer if
                negative.
        </p>
       </li>
       <li class="listitem">
        <p>
         For approximate-value numbers, the result depends on the
                C library. On many systems, this means that
         <a class="link" href="mathematical-functions.html#function_round">
          <code class="literal">
           ROUND()
          </code>
         </a>
         uses the
         <span class="quote">
          “
          <span class="quote">
           round to nearest even
          </span>
          ”
         </span>
         rule: A value with
                a fractional part exactly halfway between two integers
                is rounded to the nearest even integer.
        </p>
       </li>
      </ul>
     </div>
     <p>
      The following example shows how rounding differs for exact
            and approximate values:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa40496639"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">ROUND</span><span class="token punctuation">(</span><span class="token number">2.5</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">ROUND</span><span class="token punctuation">(</span><span class="token number">25E</span><span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> ROUND(2.5) <span class="token punctuation">|</span> ROUND(25E<span class="token punctuation">-</span>1) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 3          <span class="token punctuation">|</span>            2 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
     </div>
     <p>
      For more information, see
      <a class="xref" href="precision-math.html" title="14.24 Precision Math">
       Section 14.24, “Precision Math”
      </a>
      .
     </p>
     <p>
      The data type returned by
      <code class="literal">
       ROUND()
      </code>
      (and
      <a class="link" href="mathematical-functions.html#function_truncate">
       <code class="literal">
        TRUNCATE()
       </code>
      </a>
      ) is determined
            according to the rules listed here:
     </p>
     <div class="itemizedlist">
      <ul class="itemizedlist" style="list-style-type: circle; ">
       <li class="listitem">
        <p>
         When the first argument is of any integer type, the
                return type is always
         <a class="link" href="integer-types.html" title="13.1.2 Integer Types (Exact Value) - INTEGER, INT, SMALLINT, TINYINT, MEDIUMINT, BIGINT">
          <code class="literal">
           BIGINT
          </code>
         </a>
         .
        </p>
       </li>
       <li class="listitem">
        <p>
         When the first argument is of any floating-point type or
                of any non-numeric type, the return type is always
         <a class="link" href="floating-point-types.html" title="13.1.4 Floating-Point Types (Approximate Value) - FLOAT, DOUBLE">
          <code class="literal">
           DOUBLE
          </code>
         </a>
         .
        </p>
       </li>
       <li class="listitem">
        <p>
         When the first argument is a
         <a class="link" href="fixed-point-types.html" title="13.1.3 Fixed-Point Types (Exact Value) - DECIMAL, NUMERIC">
          <code class="literal">
           DECIMAL
          </code>
         </a>
         value, the return
                type is also
         <code class="literal">
          DECIMAL
         </code>
         .
        </p>
       </li>
       <li class="listitem">
        <p>
         The type attributes for the return value are also copied
                from the first argument, except in the case of
         <code class="literal">
          DECIMAL
         </code>
         , when the second argument is
                a constant value.
        </p>
        <p>
         When the desired number of decimal places is less than
                the scale of the argument, the scale and the precision
                of the result are adjusted accordingly.
        </p>
        <p>
         In addition, for
         <code class="literal">
          ROUND()
         </code>
         (but not for
                the
         <a class="link" href="mathematical-functions.html#function_truncate">
          <code class="literal">
           TRUNCATE()
          </code>
         </a>
         function),
                the precision is extended by one place to accommodate
                rounding that increases the number of significant
                digits. If the second argument is negative, the return
                type is adjusted such that its scale is 0, with a
                corresponding precision. For example,
         <code class="literal">
          ROUND(99.999, 2)
         </code>
         returns
         <code class="literal">
          100.00
         </code>
         —the first argument is
         <code class="literal">
          DECIMAL(5, 3)
         </code>
         , and the return type is
         <code class="literal">
          DECIMAL(5, 2)
         </code>
         .
        </p>
        <p>
         If the second argument is negative, the return type has
                scale 0 and a corresponding precision;
         <code class="literal">
          ROUND(99.999, -1)
         </code>
         returns
         <code class="literal">
          100
         </code>
         , which is
         <code class="literal">
          DECIMAL(3,
                0)
         </code>
         .
        </p>
       </li>
      </ul>
     </div>
    </li>
    <li class="listitem">
     <a name="function_sign">
     </a>
     <p>
      <a class="link" href="mathematical-functions.html#function_sign">
       <code class="literal">
        SIGN(
        <em class="replaceable">
         <code>
          X
         </code>
        </em>
        )
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045205694016">
     </a>
     <p>
      Returns the sign of the argument as
      <code class="literal">
       -1
      </code>
      ,
      <code class="literal">
       0
      </code>
      , or
      <code class="literal">
       1
      </code>
      , depending on
            whether
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      is negative, zero, or
            positive. Returns
      <code class="literal">
       NULL
      </code>
      if
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      is
      <code class="literal">
       NULL
      </code>
      .
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa86702969"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">SIGN</span><span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">32</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token operator">-</span><span class="token number">1</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">SIGN</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">0</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">SIGN</span><span class="token punctuation">(</span><span class="token number">234</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">1</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <a name="function_sin">
     </a>
     <p>
      <a class="link" href="mathematical-functions.html#function_sin">
       <code class="literal">
        SIN(
        <em class="replaceable">
         <code>
          X
         </code>
        </em>
        )
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045205678080">
     </a>
     <p>
      Returns the sine of
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      , where
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      is given in radians. Returns
      <code class="literal">
       NULL
      </code>
      if
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      is
      <code class="literal">
       NULL
      </code>
      .
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa86585193"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">SIN</span><span class="token punctuation">(</span><span class="token function">PI</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">1.2246063538224e</span><span class="token operator">-</span><span class="token number">16</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">ROUND</span><span class="token punctuation">(</span><span class="token function">SIN</span><span class="token punctuation">(</span><span class="token function">PI</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">0</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <a name="function_sqrt">
     </a>
     <p>
      <a class="link" href="mathematical-functions.html#function_sqrt">
       <code class="literal">
        SQRT(
        <em class="replaceable">
         <code>
          X
         </code>
        </em>
        )
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045205664464">
     </a>
     <p>
      Returns the square root of a nonnegative number
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      . If
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      is
      <code class="literal">
       NULL
      </code>
      , the
            function returns
      <code class="literal">
       NULL
      </code>
      .
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa83626948"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">SQRT</span><span class="token punctuation">(</span><span class="token number">4</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">2</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">SQRT</span><span class="token punctuation">(</span><span class="token number">20</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">4.4721359549996</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">SQRT</span><span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">16</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token boolean">NULL</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <a name="function_tan">
     </a>
     <p>
      <a class="link" href="mathematical-functions.html#function_tan">
       <code class="literal">
        TAN(
        <em class="replaceable">
         <code>
          X
         </code>
        </em>
        )
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045205650512">
     </a>
     <p>
      Returns the tangent of
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      , where
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      is given in radians. Returns
      <code class="literal">
       NULL
      </code>
      if
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      is
      <code class="literal">
       NULL
      </code>
      .
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa25428931"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">TAN</span><span class="token punctuation">(</span><span class="token function">PI</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token operator">-</span><span class="token number">1.2246063538224e</span><span class="token operator">-</span><span class="token number">16</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">TAN</span><span class="token punctuation">(</span><span class="token function">PI</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">+</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">1.5574077246549</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <a name="function_truncate">
     </a>
     <p>
      <a class="link" href="mathematical-functions.html#function_truncate">
       <code class="literal">
        TRUNCATE(
        <em class="replaceable">
         <code>
          X
         </code>
        </em>
        ,
        <em class="replaceable">
         <code>
          D
         </code>
        </em>
        )
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045205636528">
     </a>
     <p>
      Returns the number
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      , truncated
            to
      <em class="replaceable">
       <code>
        D
       </code>
      </em>
      decimal places. If
      <em class="replaceable">
       <code>
        D
       </code>
      </em>
      is
      <code class="literal">
       0
      </code>
      , the
            result has no decimal point or fractional part.
      <em class="replaceable">
       <code>
        D
       </code>
      </em>
      can be negative to cause
      <em class="replaceable">
       <code>
        D
       </code>
      </em>
      digits left of the decimal
            point of the value
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      to become
            zero. If
      <em class="replaceable">
       <code>
        X
       </code>
      </em>
      or
      <em class="replaceable">
       <code>
        D
       </code>
      </em>
      is
      <code class="literal">
       NULL
      </code>
      , the
            function returns
      <code class="literal">
       NULL
      </code>
      .
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa2149100"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">TRUNCATE</span><span class="token punctuation">(</span><span class="token number">1.223</span><span class="token punctuation">,</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">1.2</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">TRUNCATE</span><span class="token punctuation">(</span><span class="token number">1.999</span><span class="token punctuation">,</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">1.9</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">TRUNCATE</span><span class="token punctuation">(</span><span class="token number">1.999</span><span class="token punctuation">,</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token number">1</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">TRUNCATE</span><span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1.999</span><span class="token punctuation">,</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">        -&gt;</span> <span class="token operator">-</span><span class="token number">1.9</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">TRUNCATE</span><span class="token punctuation">(</span><span class="token number">122</span><span class="token punctuation">,</span><span class="token operator">-</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">       -&gt;</span> <span class="token number">100</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">TRUNCATE</span><span class="token punctuation">(</span><span class="token number">10.28</span><span class="token operator">*</span><span class="token number">100</span><span class="token punctuation">,</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">       -&gt;</span> <span class="token number">1028</span></code></pre>
     </div>
     <p>
      All numbers are rounded toward zero.
     </p>
     <p>
      The data type returned by
      <code class="literal">
       TRUNCATE()
      </code>
      follows the same rules that determine the return type of the
      <code class="literal">
       ROUND()
      </code>
      function; for details, see the
            description for
      <a class="link" href="mathematical-functions.html#function_round">
       <code class="literal">
        ROUND()
       </code>
      </a>
      .
     </p>
    </li>
   </ul>
  </div>
 </div>
 <br/>
</div>
