Question

Beneath you can see some calculations i am doing for my business within a big SP. I will just post a line of it here. The problem is that i cannot get the format right. It is supposed to be like this:

CONVERT(DECIMAL(30, 2), ( isa.sales_price * 0.8) * (1 - u.discount) ) as PRICE

Example of result:

  • The isa.sales_price is: 149
  • The u.discount is: 24
  • The result is: -2741.60

What am i doing wrong?

EDIT, here is the result after some help:

CONVERT(DECIMAL(30, 2), ( isa.sales_price * 0.8) * (1-(u.rabatt/100)) )
Était-ce utile?

La solution

What is wrong - I suspect - is that the calculation isn't what you expect it to be:

149 * 0.8 * (1 - 24) does indeed return -2741.60

Why do you expect it to give you something else?

If I were to venture a guess, you should divide discount with 100 as it's likely a percent value. But that's a guess.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top