Query:
declare @a float(10);
declare @b float(10);
declare @c float(10);
set @a = 150.50;
set @b = 19;
set @c = 100;
select @a * @b / @c as result
,ROUND(@a * @b / @c, 2) as rounded
Resulting in:
| result | rounded |
----------------------
| 28.595 | 28.59 |
Should the rounded be 28.60? How do I achieve this?
I think you can use the following code
declare @a float(10);
declare @b float(10);
declare @c float(10);
set @a = 150.50;
set @b = 19;
set @c = 100;
select @a * @b / @c as result
,FORMAT(ROUND(@a * @b / @c, 1),'N') as rounded
and result set will be;
+--------+---------+
| result | rounded |
+--------+---------+
| 28.595 | 28.60 |
+--------+---------+
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With