1
That’s a question that requires logical reasoning, but come on.
How to do in SQL can be function, a way to find out how many products I need to sell to reach the goal.
For example:
I sold a certain product and I need to know how many products need to be sold to get exact x real and its product value has minimum and maximum variation.
The quantity of product should be the smallest possible until it reaches real x and each product should not have a value lower than the minimum value and higher than the maximum value.
Practical example:
Meta: Vender R$ 90,00 reais
Vendi R$ 10,00 reais
Faltam R$ 80,00 reais
Valor minimo do produto: R$ 10,00 reais
Valor Maximo: R$ 20,00 reais
**Resposta**: Faltam 4 produtos de R$ 20,00 reais.
Another example:
Meta: Vender R$ 100,00 reais
Vendi R$ 10,00 reais
Faltam R$ 90,00 reais
Valor minimo do produto: R$ 10,00 reais
Valor Maximo: R$ 20,00 reais
**Resposta**: Faltam 4 produtos de R$ 20 reais e 1 produto de R$ 10,00 reais.
Another example:
Meta: vender R$ 19,00 reais
Vendi R$ 2,00 reais.
Faltam R$ 17,00 reais
Valor minimo do produto: R$ 2,00 reais
Valor Maximo: R$ 6,00 reais
**Resposta**: Faltam 2 produtos de R$ 6,00 reais e 2 produtos de R$ 2,5 reais.
The function will have 4 input parameters and one output: Input: Meta, missing value, minimum value, maximum value. Output: Answer
If it is impossible to reach the target state that on the basis of the minimum and maximum value it is not possible.
Depending on the number of products you can have thousands of different ways to achieve the goal. That’s right?
– Reginaldo Rigo
Have you developed any code ?
– Diego Souza
@Reginaldorigo I didn’t understand your comment.
– Leandro
@Gumball Not yet
– Leandro
@Leandro which bank?
– Sorack
Search by Backpack algorithm https://pt.wikipedia.org/wiki/Problema_da_backpack
– Motta
@Sorack Sql Server
– Leandro
If you post your data model it becomes easier to help
– Ricardo Pontual
@Daniel, one should prioritize the least amount of products possible. In the case of your example would be 1 product of 10 real.
– Leandro