Skip to Content
Oracle SQL and PL/SQL Handbook: A Guide for Data Administrators, Developers, and Business Analysts
book

Oracle SQL and PL/SQL Handbook: A Guide for Data Administrators, Developers, and Business Analysts

by John Adolph Palinski
August 2002
Intermediate to advanced content levelIntermediate to advanced
528 pages
10h 12m
English
Addison-Wesley Professional
Content preview from Oracle SQL and PL/SQL Handbook: A Guide for Data Administrators, Developers, and Business Analysts

The TRUNC Function

The TRUNC function is used to truncate or trim values to a specified precision. The function contains two parameters: the target column or value and the specified precision. Specifying a precision of 2 will cause the value to be truncated following the hundredths. A precision of –2 will cause the value to be truncated following the hundred. Listing 7.5 illustrates a query that uses the TRUNC function. Compare the results of this query to the values in Listing 7.4.

Listing 7.5. Using the TRUNC Function
 SQL> select last_name, wages/3, trunc(wages/3,2), trunc(wages/3,-2) 2 from employee 3 where fk_department='INT' 4 group by last_name, wages; LAST_NAME WAGES/3 TRUNC(WAGES/3,2) TRUNC(WAGES/3,-2) --------------- --------- ---------------- ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Expert PL/SQL Practices for Oracle Developers and DBAs

Expert PL/SQL Practices for Oracle Developers and DBAs

John Beresniewicz, Adrian Billington, Martin Büchi, Melanie Caffrey, Ron Crisco, Lewis Cunningham, Dominic Delmolino, Sue Harper, Torben Holm, Connor McDonald, Arup Nanda, Stephan Petit, Michael Rosenblum, Robyn Sands, Riyaj Shamsudeen
Beginning Oracle SQL: for Oracle Database 12c, Third Edition

Beginning Oracle SQL: for Oracle Database 12c, Third Edition

Lex De Haan, Tim Gorman, Inger Jørgensen, Melanie Caffrey

Publisher Resources

ISBN: 0201752948Purchase book