- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to get number located at 2 places before decimal point MySQL?
In order to get number located at 2 places before decimal point, you can use the concept of div.
Let us create a table −
mysql> create table demo1 −> ( −> value float −> ); Query OK, 0 rows affected (2.20 sec)
Insert some records into the table with the help of insert command −
mysql> insert into demo1 values(456.54); Query OK, 1 row affected (0.16 sec) mysql> insert into demo1 values(50.64); Query OK, 1 row affected (0.17 sec) mysql> insert into demo1 values(1000.78); Query OK, 1 row affected (0.13 sec)
Display records from the table using select statement −
mysql> select *from demo1;
This will produce the following output −
+---------+ | value | +---------+ | 456.54 | | 50.64 | | 1000.78 | +---------+ 3 rows in set (0.02 sec)
Following is the query to get number located at 2 places before decimal point.
mysql> select value div 10%10 from demo1;
This will produce the following output −
+-----------------+ | value div 10%10 | +-----------------+ | 5 | | 5 | | 0 | +-----------------+ 3 rows in set (0.03 sec)
Advertisements