I have to calculate for a specific date (creation date) the sales 4 weeks before and 4 weeks after (the data a need to calculate is for each week)
My blocker is to calculate the item list 4 weeks before week by week and the same for weeks after.So I have to do this query 8 times changing the date
SELECT
product,
SUM(sales)
FROM
Sales_table
WHERE
DATA <= date - 1
AND product IN (
product1,
product2,
....,
product10000
);
I have to do it for date-1, date-2..., date-4 and then date+1,...,date+4 (sometimes I have to do it for +/- 12 weeks) and do the same thing for views_table so it's like 48 queries for 10K products and it copuld generate bug in workbench. There exits any other way to do this? with TMP tables for example, and how could I write the query. Thanks.
Aucun commentaire:
Enregistrer un commentaire