How can I combine data coming from different tables.
Let's assume I have 2 tables:
First with sales:
- id shop
- id product
- date
- amount
Second with stocks:
actually, with the same structure
- id shop
- id product
- date
- amount
I need to analyze for how many days' stock there is in the shop now. For that I need to calculate the average sale per shop per day for last 20 weeks and then divide the remaining stock by the average sales rate.
How can I achieve this?