0

Need some help here. I'm trying to update a column in one of my tables to take the Spend amount from 1 column and divide it by 0.85 and display at with only 2 decimal places. I have tried the ROUND function and I am currently using the CAST function to list the field as a DECIMAL in which I've tried (38,2), (30,2), etc. and none work. Here's a copy of what I'm trying to do :

(CAST(NetMediaSpend as decimal (38,2)))/.85

and even after I run it and look at my data I still see the value stored as :

13712.941176

How do I get it to only display 2 decimals of 13712.94 ?

Alex VII
  • 930
  • 6
  • 25
  • possible duplicate of [How do I format numbers to have only two decimal places?](http://stackoverflow.com/questions/1992406/how-do-i-format-numbers-to-have-only-two-decimal-places) – Air Jun 20 '14 at 21:48

3 Answers3

1
CAST(NetMediaSpend / .85 AS DECIMAL(38,2))
Quassnoi
  • 413,100
  • 91
  • 616
  • 614
0
select format(NetMediaSpend/.85,2) from your_Table
Len_D
  • 1,422
  • 1
  • 12
  • 21
  • Note that the introduction of the comma separators will cause an issue if the value is being assigned to a numeric column. – spencer7593 Jun 20 '14 at 22:17
0

I was finally able to figure out how I needed to write it:

ROUND(CAST(NetMediaSpend as DECIMAL(30,2))/.85,2)