SQL Statement - Calculation

  • Hi,

    IF the bill amount is $500.... How do I construct the SQL statement the first $300 taxable at 3% and the balance $200 at 1%?

    Appreciate your help!

  • SELECT

    taxAmount = CASE

    WHEN billAmount > 300 THEN

    (300 * .03) + ((billAmount - 300) * .01)

    ELSE

    billamount * .03

    END

    FROM

    ....

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg
  • Hi, sorry I am new and training to learn.

    Can you advise the reason required for the below statement...

    taxAmount = CASE

  • Try reading up on the CASE statement in BOL (Books On Line)

    ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/tsqlref9/html/658039ec-8dc2-4251-bc82-30ea23708cee.htm

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg
  • Oh, and NO REASON to apologize. We all learn. 😀

    ______________________________________________________________________

    Personal Motto: Why push the envelope when you can just open it?

    If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.

    Jason L. Selburg

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply