Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 AVG

Author  Topic 

Loribrooks36
Starting Member

1 Post

Posted - 2012-11-21 : 15:35:34
I need to calculate an average of values in one field. I used the correct syntax 'Select AVG(fieldname) etc. '. However, it does not work. Is there any limitations in terms of how the database should have the information organized in order for me to be able to return the Average of values.

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2012-11-21 : 15:37:37
Show us your query
Go to Top of Page

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2012-11-21 : 23:26:56
Which error you are getting?

TO konw about AVG() function, Check this link
http://www.w3resource.com/sql/aggregate-functions/avg-function.php


--
Chandu
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-11-25 : 09:37:37
quote:
Originally posted by Loribrooks36

I need to calculate an average of values in one field. I used the correct syntax 'Select AVG(fieldname) etc. '. However, it does not work. Is there any limitations in terms of how the database should have the information organized in order for me to be able to return the Average of values.


whats the datatype of field used inside AVG? it may be that it was integer field so that result got implicitly converted to int

try AVG(field * 1.0) instead of AVG(field) and see if it gives you correct result

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -