SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 AVG
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Loribrooks36
Starting Member

1 Posts

Posted - 11/21/2012 :  15:35:34  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

USA
7174 Posts

Posted - 11/21/2012 :  15:37:37  Show Profile  Reply with Quote
Show us your query
Go to Top of Page

bandi
Flowing Fount of Yak Knowledge

India
2215 Posts

Posted - 11/21/2012 :  23:26:56  Show Profile  Reply with Quote
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

India
52317 Posts

Posted - 11/25/2012 :  09:37:37  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000