Link to home
Start Free TrialLog in
Avatar of searchsanjaysharma
searchsanjaysharma

asked on

Why the difference comes in excel and sql server while using avg function,

The sample data is attached.
When i find the average using excel for set of observations the output varies in excel and sql server.Difference--in-Output.xlsx
Avatar of PortletPaul
PortletPaul
Flag of Australia image

it's (the result) is being treated as an integer in your query, but that's not true in Excel.
see the difference this way perhaps:

select avg(data), avg(data*1.0) from table1

http://sqlfiddle.com/#!3/2efbb/2
SELECT AVG(CAST(DataIn as REAL)) AS  FROM AVGTABLE
ASKER CERTIFIED SOLUTION
Avatar of PortletPaul
PortletPaul
Flag of Australia 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
thanks & cheers, Paul