Welcome to plsql4all.blogspot.com SQL, MYSQL, ORACLE, TERADATA, MONGODB, MARIADB, GREENPLUM, DB2, POSTGRESQL.

Saturday 6 September 2014

ROUND function in Teradata

ROUND function is used to round the number of decimal places. ROUND function takes two parameters,
one is the number to round and second is the number of decimal it should round to.

You must provide second parameter otherwise it will round the number to 0 decimal.

Syntax is:-

ROUND(NUMERIC_FIELD,[ROUND_NUMBER_TO_DECIMAL]);

Example:-

SELECT ROUND(50.352,2) ROUND_TO;

--> 50.35

SELECT ROUND(50.4082,2) ROUND_TO;

--> 50.41

Note:- Above it have rounded to number to two decimal but since the 0 is second decimal so it will skip the same.

SELECT ROUND(70.5462,3) ROUND_TO;

--> 70.546

SELECT ROUND(3.6564) ROUND_TO;

--> 4



Here are 5 frequently asked questions (FAQs) about round functions in Teradata:-

1. What are round functions in Teradata?
   - Round functions in Teradata are SQL functions used to round numeric values to a specified number of decimal places or to the nearest integer. These functions are useful for formatting and presenting numeric data in a desired manner.

2. Which round functions are available in Teradata?
   - Teradata provides several round functions such as ROUND, ROUNDHALFUP, ROUNDHALFDOWN, ROUNDDOWN, ROUNDUP, TRUNC, and CEIL. Each function has its specific behavior regarding rounding and truncating numeric values.

3. How does the ROUND function work in Teradata?
   - The ROUND function in Teradata rounds a numeric value to a specified number of decimal places. It follows standard rounding rules: if the decimal part is 0.5 or greater, the number is rounded up; otherwise, it is rounded down.

4. What's the difference between ROUND and TRUNC functions in Teradata?
   - The ROUND function in Teradata rounds a numeric value to a specified number of decimal places, following standard rounding rules. On the other hand, the TRUNC function truncates a numeric value towards zero, removing the digits after the specified number of decimal places without rounding.

5. How can I round a numeric value to the nearest integer in Teradata?
   - To round a numeric value to the nearest integer in Teradata, you can use the ROUND function with zero decimal places. For example:
     
     SELECT ROUND(123.45, 0); -- Result: 123
     SELECT ROUND(123.65, 0); -- Result: 124
     
   
These FAQs should provide a good understanding of round functions in Teradata and how they can be used to manipulate numeric values effectively.

8 comments:

  1. SELECT ROUND(3.6564) ROUND_TO;

    --> 3
    will be 4.000 not 3

    ReplyDelete
  2. SELECT ROUND(50.4082,2) ROUND_TO;

    --> 50.4
    will be 50.41

    in analytics, when working on frequency categorizing such misunderstanding can srew your model

    ReplyDelete
  3. Do you know how can I round 93.735 to 93.75?

    ReplyDelete
  4. I really appreciate information shared above. It’s of great help. If someone want to learn Online (Virtual) instructor lead live training in Teradata, kindly contact us http://www.maxmunus.com/contact
    MaxMunus Offer World Class Virtual Instructor led training on Teradata . We have industry expert trainer. We provide Training Material and Software Support. MaxMunus has successfully conducted 100000+ trainings in India, USA, UK, Australlia, Switzerland, Qatar, Saudi Arabia, Bangladesh, Bahrain and UAE etc.
    For Demo Contact us:
    Name : Arunkumar U
    Email : arun@maxmunus.com
    Skype id: training_maxmunus
    Contact No.-+91-9738507310
    Company Website –http://www.maxmunus.com



    ReplyDelete

Please provide your feedback in the comments section above. Please don't forget to follow.