Golang Tutorials - Learn Go Programming with Easy Step-by-Step Guides

Explore comprehensive Golang tutorials for beginners and advanced programmers. Learn Go programming with easy-to-follow, step-by-step guides, examples, and practical tips to master Go language quickly.

Round Function In Sql in SQL

Round Function In Sql in SQL

? ROUND() Function in SQL

The ROUND() function in SQL is used to round a numeric value to a specified number of decimal places.


? Syntax:

ROUND(number, decimal_places)
  • number: The numeric value to round.

  • decimal_places: The number of digits after the decimal point.


? Example 1: Round to 2 decimal places

SELECT ROUND(123.4567, 2) AS rounded_value;

Output:

rounded_value
123.46

? Example 2: Round to whole number

SELECT ROUND(123.89, 0) AS rounded_value;

Output:

rounded_value
124

? Example 3: Round negative decimal places (to tens, hundreds)

SELECT ROUND(1234.567, -2) AS rounded_value;

Output:

rounded_value
1200

? Differences in SQL Versions:

  • MySQL: Supports ROUND(number, decimal_places)

  • SQL Server: Same syntax

  • Oracle: Also supports ROUND(date) to round dates (e.g., to nearest month)


? Use Cases:

  • Financial calculations (e.g., rounding prices or taxes)

  • Formatting results for display

  • Simplifying long decimal numbers


Want to explore CEIL(), FLOOR(), or TRUNC() for comparison?

Disclaimer for AI-Generated Content:
The content provided in these tutorials is generated using artificial intelligence and is intended for educational purposes only.
html
docker
php
kubernetes
golang
mysql
postgresql
mariaDB
sql