# Round nearest 10

Dear Experts,
Rgds.
Iqbal
###### Who is Participating?

x

Commented:
Hi
Select  round(<NUM>-1 ,-2)
0

Commented:
here's a way
``````select
( (180 + 5) /10)*10 as i0
, ( (181 + 5) /10)*10 as i1
, ( (182 + 5) /10)*10 as i2
, ( (183 + 5) /10)*10 as i3
, ( (184 + 5) /10)*10 as i4
, ( (185 + 5) /10)*10 as i5
, ( (186 + 5) /10)*10 as i6
, ( (187 + 5) /10)*10 as i7
, ( (188 + 5) /10)*10 as i8
, ( (189 + 5) /10)*10 as i9
, ( (190 + 5) /10)*10 as i10

Results

|  I0 |  I1 |  I2 |  I3 |  I4 |  I5 |  I6 |  I7 |  I8 |  I9 | I10 |
|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|
| 180 | 180 | 180 | 180 | 180 | 190 | 190 | 190 | 190 | 190 | 190 |
``````
0

Analyst ProgrammerCommented:
You may use

ROUND(<NUM>,-1)
0

Commented:
here's another:
``````select
round(180/10.0,0) * 10 as i0
, round(181/10.0,0) * 10 as i1
, round(182/10.0,0) * 10 as i2
, round(183/10.0,0) * 10 as i3
, round(184/10.0,0) * 10 as i4
, round(185/10.0,0) * 10 as i5
, round(186/10.0,0) * 10 as i6
, round(187/10.0,0) * 10 as i7
, round(188/10.0,0) * 10 as i8
, round(189/10.0,0) * 10 as i9
, round(190/10.0,0) * 10 as i10

**[Results][2]**:

|  I0 |  I1 |  I2 |  I3 |  I4 |  I5 |  I6 |  I7 |  I8 |  I9 | I10 |
|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|
| 180 | 180 | 180 | 180 | 180 | 190 | 190 | 190 | 190 | 190 | 190 |
``````
0

Author Commented:
select round(185 ,-1)

result 190

How can change it sir into nearest 100 if value is > 50 other wise not change.
0

Commented:
by using a case expression:
``````declare @n as int
set @n = 185

select
case when @n > 50 then round(@n,-2) else @n end
;

declare @n as int
set @n = 50

select
case when @n > 50 then round(@n,-2) else @n end
;
``````
0

Commented:
:)
0

Commented:
Hello,

``````DECLARE @Val Int = 185
SELECT
nearValue =
CASE
WHEN @Val % 10 <> 0 -- remainder
THEN @Val + (10-(@Val % 10))
ELSE @Val
END
``````

Best Regards,
Mohit Pandit
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.