SQLite ABS() Function

  Total Views : 207
  Comments : 0
  Keywords : SQLite abs function to return absolute value of number with example, Get absolute value of number using sqlite abs function

Here we will learn abs() function in SQLite and how to use SQLite abs() function to get the absolute value of a number.

SQLite ABS() Function

In SQLite abs() function is used to return the absolute value of a given expression. If given expression is an integer then an integer absolute value will be returned in case if given expression contains float value then float absolute value will be returned.

 

In SQLite abs() function in case if given expression value NULL then abs() function will return NULL value.

 

If we give string or BLOB value for SQLite abs() function instead of number parameter then it will return “0.0” value.

Syntax of SQLite ABS() Function

Following is the syntax of SQLite ABS() function to return the absolute value of given expression.

 

abs( expression )

In above SQLite ABS() function syntax we defined few parameters those are

 

Expression – It’s an expression or parameter to get the absolute value

 

Now we will see how to use SQLite ABS() function to get the absolute value of given number expression.

SQLite ABS() Function Examples

Following are the simple examples of using SQLite ABS() function to get the absolute value of given expression.

 

sqliteSELECT abs(-9.3);

 

abs(-9.3)

----------

9.3

 

sqliteSELECT abs(2 *-60);

 

abs(2 * -60)

-----------

120

 

sqliteSELECT abs('-60');

 

abs('-60')

----------

60.0

 

sqliteSELECT abs('Tutlane');

 

abs('Tutlane')

--------------

0.0

 

sqliteSELECT abs('1000Tutlane');

 

abs('1000Tutlane')

------------------

1000.0

 

sqliteSELECT abs('Tutlane1000');

 

abs('Tutlane1000')

----------

0.0

 

sqliteSELECT abs(NULL);

 

abs(NULL)

----------

NULL

This is how we can use SQLite ABS() function to get the absolute value of a given expression.

 Comments (0)

Be the first to give your valuable feedback

Leave a comment

  • Default Tutlane User