'How to round to n decimal places in Apache Derby JavaDB

How does one round a given value to n decimal places in Apache Derby using SQL? It should be to the nearest decimal. The SQL round function is not supported in Apache Derby.



Solution 1:[1]

Use the following to round the number to two decimal places, you can change the number 2 below to any number of digit you want to round.

cast (@number as decimal(31,2))

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Devendiran