I have a table like the following:
Date | Person | Amount_Spent
42500 A 100
42499 A 90
42498 A 95
I would like a query that can take the current date (stored as excel dates) and show people where the difference between the amount spent on a given date (42500 in this case), i.e. 100 and the average of the last 3 days (i.e. 42500 >= x >= 42498) for example, i.e. 95 is greater than a certain amount, i.e. 2.
In this example the output should be:
Person
A
Please ensure that the solution is able to cope with the fact that there will be multiple different people, some people won't spend every day also, so the query should only average the values in the average window, I guess it should include GROUP BY as a way of grouping people together.
Thanks!
Aucun commentaire:
Enregistrer un commentaire