Link to home
Start Free TrialLog in
Avatar of Rayne
RayneFlag for United States of America

asked on

average of calculation (TSQL)

Hi,

There is a table in SQL Server where it looks like that>>
Account |  MetricA | MetricB
A1      |      33      |35
B2      |      45      |31
C3      |      32      |106

How do i average those row level percentages
See the attached excel.

Select Account, MetricA, MetricB, (MetricA-MetricB)/MetricB as Change_PCT
Will give me something below >>
Account |  MetricA | MetricB| Change_PCT
A1      |      33      |35| -0.057142857
B2      |      45      |31| 0.451612903
C3      |      32      |106| -0.2


If you average the change_PCT – it gives me 6.48%. How do I get that average of change_PCT in TSQL? Average of individual row level calculation?
thank you
EEQUES1.xlsx
ASKER CERTIFIED SOLUTION
Avatar of arnold
arnold
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Rayne

ASKER

it says "Msg 195, Level 15, State 10, Line 21
'average' is not a recognized built-in function name."
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Rayne

ASKER

Thanks Gurus