
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How to round MySQL column with float values and display the result in a new column?
Let us first create a table −
mysql> create table DemoTable ( Value float ); Query OK, 0 rows affected (0.95 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(12.4567); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values(124.7884); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values(45.64643); Query OK, 1 row affected (0.46 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+---------+ | Value | +---------+ | 12.4567 | | 124.788 | | 45.6464 | +---------+ 3 rows in set (0.00 sec)
Following is the query to round float records and display the result in a new column −
mysql> select Value,ROUND(Value,2) AS RoundValue from DemoTable;
This will produce the following output −
+---------+------------+ | Value | RoundValue | +---------+------------+ | 12.4567 | 12.46 | | 124.788 | 124.79 | | 45.6464 | 45.65 | +---------+------------+ 3 rows in set (0.00 sec)
- Related Articles
- MySQL query to count occurrences of distinct values and display the result in a new column?
- Set the NULL values to 0 and display the entire column in a new column with MySQL SELECT
- Divide numbers from two columns and display result in a new column with MySQL
- Query to divide the values of two columns and display the result in a new column using MySQL wildcard?
- Extract the middle part of column values in MySQL surrounded with hyphens and display in a new column?
- Calculate average of column values and display the result with no decimals in MySQL
- MySQL query to count the duplicate ID values and display the result in a separate column
- Count duplicate ids and display the result in a separate column with MySQL
- Concatenate the column values with separate text in MySQL and display in a single column
- MySQL query to get the length of all columns and display the result in a single new column?
- Multiply values of two columns and display it a new column in MySQL?
- Count number of occurrences of records in a MySQL table and display the result in a new column?
- MySQL query to display only the column values with corresponding column having whitespace
- Setting column values as column names in the MySQL query result?
- Trying to round a calculation to two decimal places in a new column with MySQL?

Advertisements