SQLite Round() Function

  Total Views : 431
  Comments : 0
  Keywords : SQLite round() function to round the number to specified decimal values with examples, Round up number using sqlite round() function with examples

Here we will learn Round() function in SQLite and how to use SQLite Round() function to round the number to specified decimal places with examples.

SQLite Round() Function

In SQLite Round() function is used to round up the given number to specified decimal places based on the given decimal value.

 

The SQLite Round() function will always return floating-point value by rounding the number to specified decimal positions.

Syntax of SQLite Round() Function

Following is the syntax of SQLite Round() function to round up given number to specified decimal places.

 

round( number, decimal_value )

In above SQLite round() function syntax we defined few properties those are

 

number – Its source number which we need to round off.

 

decimal_value – It defines number of decimal places to round off.

 

If decimal_value is positive number means then the number rounded to near of its value.

 

In case if decimal_value omitted or negative value means then the default value 0 will be assigned and the number will be rounded to zero (0) decimal places but still the number is a floating point value.

 

In SQLite Round() function either number or decimal_value is NULL means then the SQLite Round() function will return NULL value.

 

Now we will see how to use SQLite Round() function to round up the number to specified decimal positions with examples.

SQLite Round() Function Examples

Following are the simple examples of SQLite Round() function to round off the number to specified decimal positions based on the defined value.

 

sqliteSELECT round(23.4);

 

round(23.4)

-----------

23.0

 

sqliteSELECT round(23.6);

 

round(23.6)

-----------

24.0

 

sqliteSELECT round(23.6985,2);

 

round(23.6985,2)

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

23.7

 

sqliteSELECT round(190.3985,3);

 

round(190.3985,3)

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

190.398

 

sqliteSELECT round(99.9,0);

 

round(99.9,0)

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

100.0

 

sqliteSELECT round(23.3985,NULL);

 

round(23.3985,NULL)

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

NULL

 

sqliteSELECT round(1304.67,-1);

 

round(1304.67,-1)

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

1305.0

This is how we can use SQLite Round() function to round off the number to given decimal places based on our requirements. 

 

NEXT

SQLite Commands  
 

 Comments (0)

Be the first to give your valuable feedback

Leave a comment

  • Default Tutlane User