Home Sql Mysql-example MySQL Absolute Value

Related Tutorials


 
 

Share on Google+Share on Google+

MySQL Absolute Value

Advertisement
MySQL Absolute Value is used to return the absolute value of a records in table. The keyword abs is used to return the absolute numerical value of a records in a table.

MySQL Absolute Value

     

MySQL Absolute Value is used to return the absolute value of a records in table. The keyword abs is used to return the absolute numerical value of a records in a table. It returns you the positive magnitude number irrespective of  any positive and negative numbers.

Understand with Example

The Tutorial describes you to find the Absolute Value in MySQL. To understand the example we use select query to run, that returns you the set of records from table 'emp_table'.

 

 

Query

 

 select * from emp_table;

 

Output

 

+--------+----------+-----------------+-----------+
| emp_id | emp_name | emp_designation | emp_value |
+--------+----------+-----------------+-----------+
| 1      | sandeep  | programmer      | -25.88    |
| 2      | suman    | sr. Gr Designer | 0.587     |
| 3      | ravi     | s/w developer   | 91.456    |
+--------+----------+-----------------+-----------+
 

 

In this example we use abs keywords to find the absolute value in the sql query. In the given table the column emp_value define float datatype. The select abs(emp_value) returns the numerical value without regards to its sign.

Here the absolute value display of emp_value column:

Query

 

select emp_value, abs(emp_value) from emp_table;

 

Output

 

+-----------+------------------+
| emp_value | abs(emp_value)   |
+-----------+------------------+
| -25.88    | 25.879999160767  |
| 0.587     | 0.58700001239777 |
| 91.456    | 91.456001281738  |
+-----------+------------------+

 

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: February 4, 2009

Related Tutorials

Discuss: MySQL Absolute Value  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:1
Ankit
April 24, 2012
Please help with the following query

mysql> select * from Salespeople ; +------+---------+-----------+------+ | snum | sname | city | comm | +------+---------+-----------+------+ | 1001 | Peel | London | 0.12 | | 1002 | Serres | San Jose | 0.13 | | 1003 | Axelrod | Newyork | 0.1 | | 1004 | Motika | London | 0.11 | | 1007 | Rifkin | Barcelona | 0.15 | +------+---------+-----------+------+ 5 rows in set (0.00 sec) mysql> select * from Salespeople where comm =.12; Empty set (0.00 sec)
DMCA.com