SQL Query to Remove Decimal Values
Last Updated :
06 Jan, 2025
In SQL, decimal values are often used to represent floating-point numbers. However, there are instances where we might need to remove decimal places or adjust the number of decimals in your queries.
In this article explains various methods in SQL to remove or round off decimal values, including ROUND()
, FLOOR()
, and CAST()
, providing clear examples for each method.
How to Remove Decimal Values in SQL
There are multiple ways to remove decimal values in SQL, depending on your needs. These functions help us manage and control the decimal precision:
- Using the ROUND() Function
- Using the FLOOR() Function
- Using the CAST() Function
To demonstrate these methods, let’s assume we have the following geeksforgeeks
table:

1. Using the ROUND() Function
The ROUND()
function in SQL is one of the most common ways to handle decimal values. This function rounds a number to the specified number of decimal places. If we wish to remove all decimals and round the value to the nearest integer, we can use 0 as the number of decimal places.
Syntax:
ROUND(Value, decimal_place)
Example
In this example, round the values in the MARKS
column to 0 decimal places (removing the decimals):
SELECT NAME, ROUND(MARKS,0) AS MARKS FROM geeksforgeeks;
Output

Explanation:
80.9
is rounded to 81
, as it’s closer to 81
than 80
.
86.89
becomes 87
, as 87
is the nearest integer.
- Similarly, all decimal values are rounded to the nearest whole number.
2. Using the FLOOR() Function
The FLOOR()
function in SQL returns the largest integer less than or equal to a given value. Unlike the ROUND()
function, FLOOR()
does not round up; it simply drops the decimal portion and returns the greatest integer that is less than or equal to the number.
Syntax:
FLOOR(value)
Example
The following query removes the decimal values by truncating them:
SELECT NAME, FLOOR(MARKS) AS MARKS FROM geeksforgeeks;
Output

Explanation:
80.9
is truncated to 80
.
86.89
becomes 86
, discarding the fractional part.
- No rounding occurs; the values are simply reduced to the nearest lower integer.
3. Using the CAST() Function
The CAST()
function is used to convert a value from one data type to another. If we want to remove decimal places, we can cast the floating-point number to an integer type, which automatically removes any decimal values.
Syntax:
CAST( value as datatype)
Example
The following query converts the MARKS
column to integer values:
SELECT NAME, CAST(MARKS as INT) AS MARKS FROM geeksforgeeks;
Output

Explanation:
80.9
becomes 80
.
86.89
is converted to 86
.
- Similar to
FLOOR()
, this method truncates the decimals without rounding
Conclusion
Removing or adjusting decimal values in SQL can be efficiently handled using functions like ROUND()
, FLOOR()
, and CAST()
. Each function has its unique purpose: the ROUND()
function helps round values to a specific number of decimal places, which is useful for generating more readable outputs. The FLOOR()
function removes decimals by rounding down to the nearest integer, making it suitable for scenarios where you need to ensure values do not exceed a certain threshold.
Similar Reads
SQL Query to Exclude Null Values
In relational databases, managing NULL values is a critical aspect of data integrity and accuracy. A NULL value signifies the absence of data in a column, distinguishing it from a zero, which is an integer, or a blank space, which is a character. Queries involving NULL values require careful handlin
3 min read
How to find Decimal Place Value?
We know that in mathematics, numbers are classified into different types, such as natural numbers, whole numbers, integers, rational numbers, etc. But what is a number system? A system of writing for representing numbers is referred to as a number system. There are different types of number systems,
7 min read
SQL Query to Remove Trailing Spaces
In this article, we will look at how to remove trailing spaces. Trailing spaces means the space characters from the right side. We need to use the RTRIM() function. The RTRIM function is used for removing all specified characters from the right-hand side of a string. T Syntax: RTRIM(string)Parameter
1 min read
SQL Server DECIMAL Data Type
In SQL Server, when you need numbers to be super precise, like in financial calculations, you use the DECIMAL data type. It's like a special box for storing exact numbers and no rounding off! In simpler terms, decimal is SQL Server's way of saying, "I don't mess around with numbers." It's the go-to
4 min read
How to Ignore 0(zero) Values in SQL Query?
In SQL, many times we are required to display all the rows of a table in which the entries having 0(zero) as an entry/value are ignored. This is achieved through REPLACE command in SQL. In this article, we will discuss how to ignore 0(zero) and replace them with an empty space in SQL. For this artic
2 min read
SQL Query to Delete Duplicate Rows
Duplicate rows in a database can cause inaccurate results, waste storage space, and slow down queries. Cleaning duplicate records from our database is an essential maintenance task for ensuring data accuracy and performance. Duplicate rows in a SQL table can lead to data inconsistencies and performa
6 min read
Decimal vs Double vs Float in MySQL
In MySQL, Decimal, Double, and Float are numeric data types used to represent different precision levels for numerical values. Decimal offers precise numeric storage with fixed-point arithmetic, suitable for financial data. Double and Float are approximate numeric types, where Double provides higher
6 min read
Querying Multiple Tables in SQL
SQL (Structured Query Language) is a powerful tool for managing and querying relational databases. One of its most valuable features is the ability to query multiple tables simultaneously, allowing us to retrieve and integrate related data efficiently. In this article, we will explain how to query m
4 min read
How to remove all decimals from a number using Python?
We have to remove all decimals from a number and get the required output using Python. There are several ways to achieve this, depending on whether you want to simply truncate the decimal part, round it or perform other manipulations. For example, number is 12.345 then result is 12. Using int( )int(
3 min read
MySQL Float vs Decimal
In MySQL, when dealing with numbers, you have two main choices: FLOAT and DECIMAL. Each has its unique strengths and best uses. Picking the right one is vital for accurate and efficient data handling in your database. Understanding their differences helps you make smart decisions for better performa
4 min read