I would like to know if I can get the average of a sum in one single SQL SERVER request,
Have tried to do it with the following request but it doesn’t work:
SELECT t.client,
AVG(SUM(t.asset)) AS Expr1
FROM TABLE t
GROUP BY t.client
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I think your question needs a bit of explanation. If you want to take the sums grouped by
t.clientyou can use:Then, if you want to take the average of this sume, just make:
You can’t however group the outer query, because this will give you results like in the first query. The results from the inner query are already grouped by
t.client.