0

I am trying to perform an operation in SQL server using LOG() and a few fields that are within my table. When I try and run the query, I get the error

'An invalid floating point operation occurred.'

I tried the solution provided in An invalid floating point operation occurred but I was not able to get it to solve. This was the original code that I used

SELECT 

MIN(ROUND((ROUND(Log(amt1 / ABS(rate * amt2 - amt1)),5) / (round(LOG(1 + rate),10))),0))

FROM table

WHERE amt2 - amt1 > 0 

I expected the output to show a value. I can run this for one specific field, but as I span this out to the whole data set the error occurs.

user7298979
  • 499
  • 4
  • 21
  • 1
    If `amt1 <= 0` or `rate <= -1` you'll be passing zero or a negative value to `Log()`. Did you check your data for those conditions? Aside: Since you use `Abs` in your calculation you probably should be using `... where Abs( amt2 - amt1 ) > 0;`. – HABO May 22 '19 at 17:02
  • @HABO thank you! I had to adjust the where clause and added the conditions you mentioned, then I got a dividing by zero error which I fixed by adding COALESCE/NULLIF into the division piece – user7298979 May 22 '19 at 17:08

0 Answers0