We are excited to announce that the ASP.NET Forums are moving to the new Microsoft Q&A experience. Learn more >

## 4 replies

Last post Nov 26, 2014 12:12 PM by Careed

• simflex

Member

259 Points

1191 Posts

### Is my DISCOUNT calculation correct?

We are building a website that encourages users to use the website to make online purchases.

To entice them, we give 10% discount for online purchases.

Code below shows 10% discount applied.

In other words, original price plus tax plus tip gives grossTotal.

Then 10% discount was applied after gross Total was ascertained.

Did I do this right?

```select distinct h.hourly
, h.hourly * IIf([CarTypes] = 'Sedan', 55,
IIf([CarTypes] = 'Stretch (6 Passengers)', 75,
IIf([CarTypes] = 'Stretch (8 Passengers)', 90,
IIf([CarTypes] = 'Stretch (10 Passengers)', 95,
IIf([CarTypes] = 'Stretch (12 Passengers)', 110)))))  as Fare
, h.hourly * IIf([CarTypes] = 'Sedan', 55,
IIf([CarTypes] = 'Stretch (6 Passengers)', 75,
IIf([CarTypes] = 'Stretch (8 Passengers)', 90,
IIf([CarTypes] = 'Stretch (10 Passengers)', 95,
IIf([CarTypes] = 'Stretch (12 Passengers)', 110))))) * 7/100 as Tax
, h.hourly * IIf([CarTypes] = 'Sedan', 55,
IIf([CarTypes] = 'Stretch (6 Passengers)', 75,
IIf([CarTypes] = 'Stretch (8 Passengers)', 90,
IIf([CarTypes] = 'Stretch (10 Passengers)', 95,
IIf([CarTypes] = 'Stretch (12 Passengers)', 110))))) * 20/100 as Tip
, Fare+Tax+TIP as grossTotal,
grossTotal*10/100 as Discount,
grossTotal-Discount as Total
FROM HourlyRates h
INNER JOIN carType c on h.hourly = c.hourly ```

• Careed

Star

13130 Points

4049 Posts

### Re: Is my DISCOUNT calculation correct?

I would believe that you would apply the discount on the fare only.  Note that you don't want to take the discount on the tax as you will likely still have to pay the tax as based on the original fare and you would want the tip to be independent of your fares and hope for the generosity of your passengers.

Christopher Reed, MCT, MCSD, MCPD, Microsoft Specialist, MTA, MCTS
"The oxen are slow, but the earth is patient."
• simflex

Member

259 Points

1191 Posts

### Re: Is my DISCOUNT calculation correct?

Thanks a lot for clarifying this.

Just one more clarification just say I got it right.

The code would then be:

Fare*10/100 as Discount?

Then assume the discount amount is \$15.00, do I then deduct this from the overall total amount or do I still need to subtract it from the fare?

Much appreciated.

• Kevin Shen -...

All-Star

16806 Points

2777 Posts

### Re: Is my DISCOUNT calculation correct?

Nov 26, 2014 08:15 AM|Kevin Shen - MSFT|LINK

Hi simflex,

Based on my understanding,If you want to  give discount on the gross total ,you are in the right way.

If you want to give a discount on the fare, you can set Fare*10/100 as Discount ,and just deduct this from gross total.

Best Regards,

Kevin Shen.

• Careed

Star

13130 Points

4049 Posts