Hello,
I have a Money column in my SQL Server 2008 table. In my below query how can I round it to nearest 5$
select FineAmount from tickets
Thanks
Hello,
I have a Money column in my SQL Server 2008 table. In my below query how can I round it to nearest 5$
select FineAmount from tickets
Thanks
A general math solution:
Divide by 5, round to the nearest integer, then multiply by 5.
select round(FineAmount*2,-1)/2 from tickets
or to put nicholaides suggestion in sql
select round(FineAmount/5,0)*5 from tickets
The example assumes that FineAmount is of type money. The second approach is probably better as the first one works with the limit of maximum_value_of_money_type/2
More on ROUND