Reputation: 2135
I want to round to the nearest half decimals (geo coordinates) to do some data visualization. In t-sql, is there a built in function to round to half decimals (if that is the term). Examples of desired result:
1.1 > 1.0
1.4 > 1.5
1.6 > 1.5
1.9 > 2.0
Upvotes: 3
Views: 4851
Reputation: 700152
Just multiply by 2, round, and divide by 2.
select round(1.1 * 2, 0) / 2 -- > 1.0
select round(1.4 * 2, 0) / 2 -- > 1.5
select round(1.6 * 2, 0) / 2 -- > 1.5
select round(1.9 * 2, 0) / 2 -- > 2.0
Upvotes: 12