-2

I would like the average to be average excluding the current month counts.
I.e for November the average would calculated based on Jan-September values.

How do I do this using SQL Server 2008?

  • Please update your question to include table definitions (DDL) and sample data in the form of insert statements. Also specify expected results. – Scott Hodgin Jan 22 '19 at 19:13
1

Just add a predicate to filter out the current month's rows.

where yourDataColumn <  DATEADD(month, DATEDIFF(month, 0, getdate()), 0)
| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.