I have a table ProductionRate with fields ProductionDate as Date and Qty as Integer. I want to perform the average from the current day (if the Qty is available) to the Monday of the week, and subsequently for all prior week in the descending order.
For example, if today is Wednesday and the qty is available, I want to obtain an average of qty of Monday, Tuesday and Wednesday, and also I want to obtain the average of all the prior week as the return of the SQL statement. This means that the return of the SQL statement will display the first value as the average of the current week (depending on the current day) and subsequently all average of the prior week in descending order. I have Monday-Friday per working week.
Please advice me with a sample SQL statement on how this could be done.
Regards.
Start Free Trial