How can I round up the values to the multiples of 0.5 in SQL Server.
I tried using CEILING , ROUND and CASE functions.
CEILING
ROUND
CASE
vjhs03f71#
ROUND(<value> * 2, 0) / 2
So, you multiply the input value by 2, rounding it to the nearest integer, then dividing it by 2 to get to the nearest multiple of 0.5
lmvvr0a82#
To round up to the nearest 0.5 double, then take the ceiling then divide by 2.
declare @n decimal(12,4) = 12.0 select ceiling(2.0*@n)/2.0
2条答案
按热度按时间vjhs03f71#
So, you multiply the input value by 2, rounding it to the nearest integer, then dividing it by 2 to get to the nearest multiple of 0.5
lmvvr0a82#
To round up to the nearest 0.5 double, then take the ceiling then divide by 2.