I have a database table with the following structure –
Week_End Sales
2009-11-01 43223.43
2009-11-08 4324.23
2009-11-15 64343.23
...
What I want is a SQL statement that will take a start and end date, and identify all rows within that period where the sales figure is more than 3% above or below the average sales figure for that period. So, run against the above data, it would return –
Week_End Sales
2009-11-08 4324.23
I am using SQL Server 2008, btw.
note: the average in your example is 37297, so all three values in the table end up being outside the tolerance.