Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AVG in Sql - Float number problem

Tags:

sql

average

People also ask

How do I get the average of a decimal in SQL?

SQL CAST() inside AVG() for decimal valueThe SQL AVG() function returns the average value with default decimal places. The CAST() is used to increase or decrease the decimal places of a value. The CAST() function is much better at preserving the decimal places when converting decimal and numeric data types.

Does SQL AVG ignore 0?

To exclude entries with “0”, you need to use NULLIF() with function AVG().

What does AVG () do in SQL?

The AVG() function returns the average value of a numeric column.


Try

Select
    AVG(Cast(variable as Float)),
    SUM(variable)
From
    Table