Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi there,
I have the following problem:
I have a table containing article-data (sample-data):
| ARTICLE_ID | PRODUCTGROUP_ID | STARTDATE | ADDED_AT_DATE | VALUE |
|---|---|---|---|---|
| 1 | 1 | 1 | 1 | 100 |
| 1 | 1 | 5 | 1 | 200 |
| 2 | 2 | 1 | 1 | 300 |
| 3 | 2 | 1 | 3 | 400 |
Now what I need to do is to add a field to every row of this table.
Those fields are calculated by summing up all values of the table which have the same productgroup-id as in the current row and also need to have added_at_date in between the startdate and the startdate + 7.
Is there an efficient way to solve this problem?
I tried to create a new table called productgroup, which contains data like the productgroup_id, added_ad_date and dailyvalue (dailyvalue is an accumulation of all values for every productgroup_id and added_ad_date).
Doing so I am clueless about how to accumulate the data out of this table for every article_id in the article-table, since it would need to be accumulated for every row over a dynamic amount of rows in the productgroup-table.
I hope you can help me with ideas or techniques to solve this problem ![]()
First I seperate the data into productgroups.
After this I take every article_id and sum up all values, whose added_at_date lies within the initial startdate and the startdate + 7 of the article_id-row.
