How to get money column rows in sql with more than two precision digits to the right of the decimal?

Itโ€™s hard for me to figure out how to select a rowset from my table, where the accuracy of the row value is more than two digits to the right of the decimal point. I do not need any of the values โ€‹โ€‹that have double-digit precision. I only need those that have an accuracy of more than two digits. The end result is that values โ€‹โ€‹with an accuracy of more than two digits must be rounded to limit the values โ€‹โ€‹to an accuracy of two digits. The code into which the data is inserted has been fixed to insert values โ€‹โ€‹accurate to 2 digits, but I need to fix the ones that are not.

+4
source share
2 answers

Hey, your goal is to find these records and then update them? below is what i need to do:

DECLARE @smallmoney as money set @smallmoney = 1.0097 SELECT @smallmoney as actualValue, ROUND(@smallmoney,2) WHERE @smallmoney <> ROUND(@smallmoney,2) 

As you can see, if the amount of money is already within two decimal places, the where clause will filter this entry.

Hope this works for you!

+1
source

I was hunting for the answer to the same problem where some of the script I wrote created a column of money more than 2 decimal places - for example, you had to go and find records that were more than 2 DP - could not find the answer to SO , found below the answer elsewhere.

 select ID, MoneyColumn from OurTable WHERE FLOOR(MoneyColumn*100)!=MoneyColumn*100 
+1
source

Source: https://habr.com/ru/post/1333576/


All Articles