|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
|
I am trying to round values to the nearest $5.
I work in the casino industry and we offer patrons cashback on thier play. Let's say someone earns $42 cash back. I need to send them an extra check for 25% rounded to the nearest $5. $42 * 25% = 10.5 which I need to round to $10 $53 * 25% = 13.25 which I need to round to $15 Similiar to basic rounding...2.49 rounds to 2 and 2.5 rounds to 3 I need 12.49 to round to 10 and 12.50 to round to 15. Does anyone know how to mathamatically program SQL to do so? Is there a function that can help out? Thanks.
Show quote
"Brian Shannon" <brian.shan***@diamondjo.com> wrote in message declare @num1 intnews:eSEbcu1TGHA.4384@tk2msftngp13.phx.gbl... >I am trying to round values to the nearest $5. > > I work in the casino industry and we offer patrons cashback on thier play. > Let's say someone earns $42 cash back. I need to send them an extra check > for 25% rounded to the nearest $5. > > $42 * 25% = 10.5 which I need to round to $10 > $53 * 25% = 13.25 which I need to round to $15 > > Similiar to basic rounding...2.49 rounds to 2 and 2.5 rounds to 3 I need > 12.49 to round to 10 and 12.50 to round to 15. > > Does anyone know how to mathamatically program SQL to do so? Is there a > function that can help out? > > Thanks. declare @num2 int set @num1 = 42 set @num2 = 53 select cast((@num1 * .25)/5 as decimal(5,0)) * 5 select cast((@num2 * .25)/5 as decimal(5,0)) * 5 Thanks...I tried multiple scenerios and it worked in all cases.
Show quote "Raymond D'Anjou" <rdanjou@canatradeNOSPAM.com> wrote in message news:%23e4oa11TGHA.4520@TK2MSFTNGP10.phx.gbl... > "Brian Shannon" <brian.shan***@diamondjo.com> wrote in message > news:eSEbcu1TGHA.4384@tk2msftngp13.phx.gbl... >>I am trying to round values to the nearest $5. >> >> I work in the casino industry and we offer patrons cashback on thier >> play. Let's say someone earns $42 cash back. I need to send them an >> extra check for 25% rounded to the nearest $5. >> >> $42 * 25% = 10.5 which I need to round to $10 >> $53 * 25% = 13.25 which I need to round to $15 >> >> Similiar to basic rounding...2.49 rounds to 2 and 2.5 rounds to 3 I need >> 12.49 to round to 10 and 12.50 to round to 15. >> >> Does anyone know how to mathamatically program SQL to do so? Is there a >> function that can help out? >> >> Thanks. > > declare @num1 int > declare @num2 int > > set @num1 = 42 > set @num2 = 53 > > select cast((@num1 * .25)/5 as decimal(5,0)) * 5 > select cast((@num2 * .25)/5 as decimal(5,0)) * 5 > |
|||||||||||||||||||||||