truncate function

The trunc function truncates the value of an input expression to the specified decimal places on the right of the decimal point.

Syntax:

double trunc(n [, d ])

Semantics:

Example 1 - truncate function

SELECT trunc(n,d) FROM Userstocks
Value of n Value of d Output
111.567 0 or not specified 100.00
111.567 2 100.56
111.567 3 111.567
111.567 -2 100.0
111.567 -3 0.0
-111.567 2 -100.567
-111.567 -1 -110.0