S.M_Emamian
S.M_Emamian

Reputation: 17383

How to define a table to calculate discounts on bills

I want to create a table to calculate discounts on bills for sale manager depend on total price for a customer.

example:

if total_price equal 100$, the discount will be 0.

if total_price between 100$ and 200$, the discount will be 0.02%.

if total_price between 200$ and 300$, the discount will be 0.04%. and so on.

how can I create a correct schema to this purpose?

Upvotes: 0

Views: 101

Answers (1)

Olivier Meurice
Olivier Meurice

Reputation: 562

Create a table with three columns: lower, upper and discount. Given a value you can query the table like this: select discount from your_table where lower < value and value <= upper

Upvotes: 1

Related Questions