There are 3 tables - Discounts(Discount) Customers(Clients) and Orders(Orders)
Discount
------------------------------------------------
|id_discount | count_orders | percent_discount |
------------------------------------------------
| 1 | 5 | 1,5 |
| 2 | 10 | 2,5 |
Clients
------------------------------------------------
| id_client | Name | Surname |
------------------------------------------------
| 1 | Ivan | Petrov |
| 2 | Vasya | Vasev |
Orders
------------------------------------------------
| id | order_sum | id_client |
------------------------------------------------
The question how to calculate the total amount, given the number of orders made by the client? If the total number of orders 5 and above, the discount is 1.5%, if 10 and above, 2.5%. Otherwise, no discount. Thanks in advance