SQL ROUND() Function



SQL ROUND() Function

ROUND() – The ROUND() function used to rounds the value and returns it.

The syntax of ROUND() is:

SELECT ROUND(col_name, decimal) FROM Table_Name
sql round() function
How to use SQL ROUND() Function

Let’s understand ROUND() function with an example :

We have SQL Table StudentMst with below column.

SELECT * FROM StudentMst

ID Name City Amount Mobile
1 Meera Bombay 125.50 7874555555
2 Rahul Surat 120.5 7874444444
3 Jayesh Ahmedabad 11.25 7874333333
4 Dhvanish Bombay 120.125 7874111111
5 Reena Baroda 100.60 7874666666
6 Veera Baroda 12.25 7874121212

SELECT ID,Name,City,ROUND(Amount,0) AS AMOUNT FROM StudentMst

ID Name City Amount
1 Meera Bombay 126
2 Rahul Surat 121
3 Jayesh Ahmedabad 11
4 Dhvanish Bombay 120
5 Reena Baroda 101
6 Veera Baroda 12

SELECT ID,Name,City,ROUND(Amount,1) AS AMOUNT FROM StudentMst

ID Name City Amount
1 Meera Bombay 125.5
2 Rahul Surat 120.5
3 Jayesh Ahmedabad 11.3
4 Dhvanish Bombay 120.1
5 Reena Baroda 100.6
6 Veera Baroda 12.3

SELECT ID,Name,City,ROUND(Amount,2) AS AMOUNT FROM StudentMst

ID Name City Amount
1 Meera Bombay 125.5
2 Rahul Surat 120.5
3 Jayesh Ahmedabad 11.25
4 Dhvanish Bombay 120.13
5 Reena Baroda 100.6
6 Veera Baroda 12.25

Leave a Reply

Your email address will not be published. Required fields are marked *