Get Only Floating Point Numbers from a List of Values in MySQL



Let us first create a table −

mysql> create table DemoTable628 (Value DECIMAL(10,2));
Query OK, 0 rows affected (0.52 sec)

Insert some records in the table using insert command −

mysql> insert into DemoTable628 values(10.97);
Query OK, 1 row affected (0.13 sec)
mysql> insert into DemoTable628 values(20.04);
Query OK, 1 row affected (0.18 sec)
mysql> insert into DemoTable628 values(12.00);
Query OK, 1 row affected (0.17 sec)
mysql> insert into DemoTable628 values(89.56);
Query OK, 1 row affected (0.20 sec)

Display all records from the table using select statement −

mysql> select *from DemoTable628;

This will produce the following output −

+-------+
| Value |
+-------+
| 10.97 |
| 20.04 |
| 12.00 |
| 89.56 |
+-------+
4 rows in set (0.00 sec)

Following is the query to get floating point numbers from a list −

mysql> select *from DemoTable628
   where Value!=FLOOR(Value);

This will produce the following output −

+-------+
| Value |
+-------+
| 10.97 |
| 20.04 |
| 89.56 |
+-------+
3 rows in set (0.00 sec)
Updated on: 2019-08-23T07:38:43+05:30

475 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements