Reputation: 1
How do I get the average cost per visit in a TSQL statement?
I have the total count of visits and summed the cost.
Upvotes: 0
Views: 761
Reputation: 238176
If you have the total count and summed cost, the average is just a division away:
summed cost
------------- = average cost
total count
Upvotes: 0
Reputation: 539
Can't you simply divide the number of visits by the total cost? (I.e., SUM(Cost) / SUM(Count))
Upvotes: 0
Reputation: 22403
You can use the AVG
aggregate function:
http://msdn.microsoft.com/en-us/library/ms177677.aspx
Upvotes: 2