Thursday 21 May 2015

MSSQL - SQLServer - How to Calculate Average of Multiple Columns

Watch this example on YouTube:

Here is my table:



I want to know average of Bonus, Salary and Gambling for each user.
The following query will calculate it:
Select CustomerName ,
  (Select AVG(MyAverage) From (Values (Bonus), (Salary), (Gambling)) as TblAverage(MyAverage))
From Table3











No comments:

Post a Comment