Hello,
after decades I'm working again with databases. I need a database with bulk prices. The overal structure of that database isn't the problem, but the query. My current structure looks like:
- ProductID: a unique number for every product [INTEGER, PRIMARY KEY]
- PriceID: ascending number for each bulk price [INTEGER, PRIMARY KEY]
- CountMin: the minimum number for that bulk price [INTEGER]
- CountMax: the maximum number for that bulk price [INTEGER]
- Price: the bulk price [FLOAT]
Code:
ProductID PriceID CountMin CountMax Price
1 1 1 4 1000
1 2 5 9 985
1 3 10 24 955
1 4 25 99 895
1 5 100 10000 800
2 1 1 4 100
2 2 5 9 98
2 3 10 24 95
2 4 25 99 89
2 5 100 10000 800
The first CountMin value is always 1. In that example table the last CountMax value is set to 10000, exactly the value should be infinite.
My question: The query for a given ordered number (e. g. 12) of a product with "ProductID=2"? Result should be 95.
Many thanks for any hints
dbenthusiast