Let's TRUNCATE!

TRUNC

Syntax: TRUNC( number [,decimal precision] )

Parameter: number is a source number or column containing source number. decimal precision specifies the degree of truncation and is the optional parameter. If decimal precision parameter is absent, the default degree of rounding is zero, which means source number is truncated to nearest whole number.

Return type: TRUNC function (when it applies to numeric value) returns a number.

Usage:
Manager wants to fill the online report where in the salary section, online system only allows manager to fill two places after decimal point.

Manager to Data analyst: Bring me the list of all employees and their salaries with only two digits after decimal point. Data analyst runs the below query to fetch the required data.


SELECT EMPLOYEE_ID, FIRST_NAME, LAST_NAME, TRUNC(SALARY, 2) FROM EMPLOYEES;

Comments

Popular posts from this blog

Let's learn Left Outer Join!

Let's extract STRING!

Let's learn Cross Join!