Okay so I have a table and in one column I have some data and the second column the average of the data. Example
id|Data|avg
1 |20 |20
2 |4 |12
3 |18 |14
How do I populate the avg column on insert with the running average of the Data column using T-SQL?
EDIT: Sorry guys, this was actually a stupid mistake I made. I assumed I had SQL 2014 but after trying Stephan's code and getting some errors, I went back to confirm and realize I use SQL 2008. Sorry for the misinformation. I have also updated the tags