Oracle Introduction to SQL Tutorial – 4

Hi everyone, we continue with the topic of functions. You can read the previous functions article here.

 

Raund Function

Used to round the numeric values that result from a SQL query to an upper or lower integer.

Usage of: Select round(column_name, number of digits to exclude) from table name
SELECT PROD_LIST_PRICE FROM SH.PRODUCTS;

blank

If you want to print on the screen by round function according to the upper or lower value.

blank

 

Trunct Function

It is used to shorten the numerical values that result from the SQL query according to the desired decimal number.

Usage of: Select trunc (column_name, number of digits to subtract) from table_name;

SELECT PROD_LIST_PRICE FROM SH.PRODUCTS;

blank

SELECT TRUNC(PROD_LIST_PRICE,1) FROM SH.PRODUCTS ORDER BY PROD_LIST_PRICE ASC;

 

blank

As shown in the picture, a digit was omitted after the comma.

 

Mod function

Used to represent the remainder of the numerical values from the integer part.

Usage of: Select Mod (column_name, integer to divide) from table_name;

Let’s create a query by combining the functions we just saw.

 

SELECT PROD_LIST_PRICE FROM SH.PRODUCTS order by prod_list_price;

blank

 

Let’s use multiple function,

select mod(round(prod_list_price,0),3) from sh.products order by prod_list_price;

blank

As shown in the picture, we first rounded with the round function, then we took the mode of the rounded number.

 

See you in the next article..

 116 views last month,  3 views today

About Deniz Parlak

blank
Hi, i’m Security Data Scientist & Data Engineer at My Security Analytics. I have experienced Advance Python, Machine Learning and Big Data tools. Also i worked Oracle Database Administration, Migration and upgrade projects. For your questions parlak.deniss@gmail.com

Check Also

blank

Create Table ( CTAS ) and Data Types, LOB Data Types in Oracle SQL | Oracle SQL Tutorials -27

Hi, I will explain Create Table ( CTAS ) and Data Types in Oracle SQL in …

Leave a Reply