TRUNC Function in Oracle SQL – PLSQL

The TRUNC function in Oracle SQL / PLSQL is used to get a number truncated to specific number of decimal places.

Syntax for the TRUNC function in Oracle SQL / PLSQL is:

SELECT TRUNC(N,D)
FROM table_name;

  • N is the number to be truncated
  • D is the decimal places up to which N is to be truncated

Example 1:

SELECT TRUNC(1.23456,4)
FROM DUAL; 

Will return “1.2345”


Example 2:

SELECT TRUNC(1.23456,3)
FROM DUAL;

Will return “1.234”


Example 3:

SELECT TRUNC(1.23456,2)
FROM DUAL;

Will return “1.23”


Example 4:

SELECT TRUNC(-1.23456,3)
FROM DUAL;

Will return “-1.234”


Example 5:

SELECT TRUNC(1.23456)
FROM DUAL;

Will return “1”


Tagged , , , , , , , , , , , . Bookmark the permalink.