From the course: Oracle Database 12c: Basic SQL
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Using TRUNC - Oracle Database Tutorial
From the course: Oracle Database 12c: Basic SQL
Using TRUNC
- Similarly to round, another SQL function that allows us to deal with trailing digits following a decimal point is the trunk function. Trunk, unlike round, actually chops off numbers or digits following a decimal point, instead of rounding them up. Let's see it in action. We'll start by selecting a constant static value of 999.98765 from dual. Selecting the value as is will return the value as is. However, adding the trunk function, specifying the number inside brackets, comma and how many digits I want to remain after my decimal point, let's start with three. Running the query again will change the output to 999.987 as the trunk function left me with three digits following my decimal point. The rest was chopped off. Specifying one will modify my output to one digit following the decimal point. And specifying zero will get rid of all digits following the decimal point. Note that trunk, unlike round, will not round up or down any values. And of course, instead of specifying a constant…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
Introduction to functions1m 39s
-
(Locked)
Using SUBSTRING, LENGTH, and CONCAT2m 50s
-
(Locked)
Using LENGTH1m 4s
-
(Locked)
Using CONCAT4m 48s
-
(Locked)
Using LOWER and UPPER2m 44s
-
(Locked)
Using INSTR4m 32s
-
(Locked)
Using RPAD and LPAD3m 31s
-
(Locked)
Using TO_CHAR to convert numbers1m 34s
-
(Locked)
Using TO_CHAR to format DATE values2m 59s
-
(Locked)
Using TO_CHAR to filter DATE values1m 57s
-
(Locked)
The special Oracle DUAL table1m 18s
-
(Locked)
Using ROUND1m 15s
-
(Locked)
Using TRUNC1m 36s
-
(Locked)
Using SYSDATE1m 59s
-
(Locked)
Using SYSTIMESTAMP1m 37s
-
(Locked)
Using MONTHS_BETWEEN3m 2s
-
(Locked)
Using ADD_MONTHS1m 17s
-
-
-
-
-
-