1. SELECT
    2. CAST(sum(number)/count(number) as UNSIGNED) as average,
    3. date
    4. FROM stats
    5. WHERE *
    6. GROUP BY date

    the valid types for a CAST in MySQL are as follows

    • BINARY[(N)]
    • CHAR[(N)]
    • DATE
    • DATETIME
    • DECIMAL[(M[,D])]
    • SIGNED [INTEGER]
    • TIME
    • UNSIGNED [INTEGER]