Skip to content
Advertisement

How to calculate a group average in SQL?

I have a sql data set which look something like:

I would like to be able to select the data in such a way that the query will return:

With the average result calculated over the 3 years shown for each person.

How could I achieve this in SQL Server?

Advertisement

Answer

I think you want a window function:

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement