AVG to return floating value


  • 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,



    Thursday, November 08, 2012 4:50 PM


  • Hi,

    Do as below

    SELECT AVG( CAST(MyIntegerField as FLOAT)) from MyTable 

    PS.Shakeer Hussain

    • Marked as answer by sourises Thursday, November 08, 2012 6:46 PM
    Thursday, November 08, 2012 4:52 PM

All replies