My have interger type field in my table and would like to calcuate the Average resut.
I use following code.
SELECT AVG(MyIntegerField) from MyTable
The result always integer. The average result could be float, since it use sum of value divide by the number of items.
I would like to know is it possible to have ACG(IntegerField) to get float result or I need specific to ask SQL return float result.
If yes, can you please advise the sample code to do this?
Your help and information is great appreciated,
Do as below
SELECT AVG( CAST(MyIntegerField as FLOAT)) from MyTable
Thanks a million for helping and information,
Microsoft is conducting an online survey to understand your opinion of the Msdn Web site. If you choose to participate, the online survey will be presented to you when you leave the Msdn Web site.
Would you like to participate?