To explain, I prefer an example:
I want to find out which item is best sold along with salted chicken.
For this, I tried the following approach and failed miserably due to lack of technical knowledge:
-Find all coupons (sales) that contain the chicken salted code [OK]
- Collect all items from these coupons [OK]
- Take the individual quantity of each item that is sold. The highest value is the result.
I tried to use SQL only. The relevant structure of the tables is as follows:
Table product
codbarra | description
Table sale
idvenda | dtvenda
Table vdaitem
idvdaitem | vdaitem | codbarra | qtde | dtvenda