Round Money to Nearest Quarter


  
 
  
 create table test (col decimal(10,2))
Insert into test values(1.33),(2570.47),(100020.10),(100.62),(100.63),(99.99)

select Cast(Round(col * 4,0)/4.0 as decimal(10,2))  col from test
 
select 
cast(col as int)+ 
Case
when col%1 <= 0.12     then 0.00
when col%1 > 0.12  And col%1 <= 0.37  then .25
when col%1 > 0.37  and col%1 <= 0.62  then .50
when col%1 > 0.62  and col%1 <= 0.87  then .75
when col%1 > 0.87  then 1.00
end
 

from test


drop table test


 --https://social.msdn.microsoft.com/Forums/en-US/c22b2cac-0a78-4d61-bfcc-00d2e2d22303/round-to-nearest-25-cents?forum=transactsql
 

 
Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s