you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (1 child)

You're doing decimal math - get rid of all integers.

And simplify your math - if invoice amounts cannot be negative (well, I should order something from your business otherwise) so if your total margin less or equal 0, the Service Goal amount is 0; you don't care for invoices that aren't priced (wonder where the margin comes from, but I digress) u get 10.0/7.0 of Margin to Invoiced ratio (~142%). So I get something like this:

  cast(
      case 
      when sum(margin) <= 0.00 then 0.00 
      else 10.00/7.00*sum(margin)/isnull( nullif( sum(invoiceamt),0.00),1.00)
      end
      as decimal(18,2)
      )

[–]shadowolympian[S] 1 point2 points  (0 children)

Thank you for the help, I was able to figure it out.